关于document.close()
都说如果用了document.write(),就一定要用close()函数,否则不会输出结果。
可是我自己试验了,不用close也能正常输出啊?
到底close要不要用,什么情况下必须使用?
我的代码:
<head>
<title> Insert title here </title>
<script type= "text/javascript ">
function output(){
document.write( " <B> HelloWorld! </B> ");
}
</script>
</head>
<body>
<input type= "button " value= "O " id= "btnOpen " name= "btnOpen " onclick= "output() ">
</body>
------解决方案--------------------You should not use the write or writeln methods on the current document after the document has finished loading unless you first call the open method, which clears the current document 's window and erases all variables.
Note When document.write or document.writeln is used in an event handler, document.close should also be used.