close() 方法可关闭一个由 document.open 方法打开的输出流,并显示选定的数据。
</>code
- document.close()
该方法将关闭 open() 方法打开的文档流,并强制地显示出所有缓存的输出内容。如果您使用 write() 方法动态地输出一个文档,必须记住当你这么做的时候要调用 close() 方法,以确保所有文档内容都能显示。
一旦调用了 close(),就不应该再次调用 write(),因为这会隐式地调用 open() 来擦除当前文档并开始一个新的文档。
</>code
- <html>
- <head>
- <script type="text/javascript">
- function createNewDoc()
- {
- var newDoc=document.open("text/html","replace");
- var txt="<html><body>Learning about the DOM is FUN!</body></html>";
- newDoc.write(txt);
newDoc.close()
;- }
- </script>
- </head>
- <body>
- <input type="button" value="Write to a new document"
- onclick="createNewDoc()">
- </body>
- </html>
如对本文有疑问,请提交到交流论坛,广大热心网友会为你解答!! 点击进入论坛
Powered by 365建站网 RSS地图 HTML地图
copyright © 2013-2024 版权所有 鄂ICP备17013400号