代码1:
<script>
function x(){
document.write("<P>"+"语句1"+"<p>")
//document.close();
document.write("语句2"+"<p>");
document.write("语句3");
}
</script>
</head>
<body>
<input type="button" value="click" onclick="x()">
</body>
注释处添加document.close(); 会屏蔽语句1;代码2:
<script>
document.write("<P>"+"语句1"+"<p>")
document.close();
document.write("语句2"+"<p>");
document.write("语句3");
</script>
</head>
<body>
</body>
把方法里面的语句块拿到外面来,不使用方法,document.close( )为什么不起作用呢?
小弟刚学的啊,不明白的。
<script>
function x(){
document.write("<P>"+"语句1"+"<p>")
//document.close();
document.write("语句2"+"<p>");
document.write("语句3");
}
</script>
</head>
<body>
<input type="button" value="click" onclick="x()">
</body>
注释处添加document.close(); 会屏蔽语句1;代码2:
<script>
document.write("<P>"+"语句1"+"<p>")
document.close();
document.write("语句2"+"<p>");
document.write("语句3");
</script>
</head>
<body>
</body>
把方法里面的语句块拿到外面来,不使用方法,document.close( )为什么不起作用呢?
小弟刚学的啊,不明白的。
解决方案 »
- ext3的toolbar怎么动态添加3个按钮????????????????
- 如何让js堵塞在代码的某一处,当条件达到时在继续执行?
- javascript函数内部调用自身函数 这样好吗
- 学生的福音:《做错之题管理》
- eval解析json的数据,放在创建的table里显示没有效果
- 怎样获取mediaplayer或者realplayer object的状态
- ???我想只input的类型为text的元素定义样式怎么写
- [在线等]一个不知道能不能实现的问题?
- 请教各位大侠,如何实现左右frame,点击当中的边框,其中一个页面cols="0,80%",在点击一下,cols="180,80%"
- 请教:如何用Javascript判断日期格式是否正确?
- 我的Js无法实现td背景图片更换 求助。。。
- 关于几个标签的问题
而装载完以后document.close()会关闭输入流,如果再次执行
write会重新清空页面开启输入流。你用firebug设置断点的话可以很明显
的看到页面的变化,若注释掉先输出a____ 然后b____
document.open();//这个方法好像可有可无
document.writeln("a___");
//document.close();
document.writeln("b___");
document.close();
若不注释掉输出a____ b____
此外若最后一个close被注释掉则可以但到虽然也输出a____ b____
但可以看到页面一直没有加载完毕说明他还在等待输入
要有一个触发事件
如
<body>
<input type="button" value="关闭" onclick="document.close();"/>
</body>
单击 关闭 按钮 页面就会关闭 这里触发了 单击 事件 onclick