JavaScript中输出信息的方法(信息确认框-提示输入框-文档流输出)

时间:2016-06-12    点击:170   

js中输出信息的方法内容如下所示:

1、文档流输出

document.write('hello');

2、输出信息提示框 模态对话框

window.alert('要输出显示的内容'); 或 alert('要输出显示的内容');
alert(n);

3、信息确认框

var f = window.confirm('是否要进入新浪网'); confirm("");
if(f){
location.href = 'http://www.sina.com.cn'; 
}

4、提示输入框

window.prompt
var n = window.prompt('请输入年龄',18);
if(n>=18){
document.write('欢迎你年轻人'); 
}

5、控制标签,在标签上直接输出,

通过document.getElementById('id') 找到对象标签,可以直接控制里边的值,进行输出

setInterval(function(){document.getElementById('ttt').innerHTML = "当前时间:"+new Date().toLocaleString();},1000);

<script>
document.getElementById('uname').value = "佚名";
</script>

6、把信息直接输出到标题

document.title = "hello";

以上所述是小编给大家介绍的JavaScript中输出信息的方法(信息确认框-提示输入框-文档流输出),希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对本站网站的支持!

JavaScript_object基础入门(必看篇)
JavaScript遍历求解数独问题的主要思路小结
Node.js环境下编写爬虫爬取维基百科内容的实例分享
jQuery遍历json的方法(推荐)
jQuery通过ajax请求php遍历json数组到table中的代码(推荐)
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved