小白教程
所有教程
关于
Search
172.70.179.89
172.70.179.89
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Met doc close”的源代码
本页内容
上一节:
Prop_doc_body
下一节:
Prop_doc_cookie
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:document.close()}}[[Category:dom obj document|7]] = HTML DOM close() 方法 = [[dom obj document|Document 对象]] == 定义和用法 == '''close()''' 方法用于关闭一个由 '''document.open''' 方法打开的输出流,并显示选定的数据。 == 语法 == <pre> document.close()</pre> == 浏览器支持 == 所有主要浏览器都支持 close() 方法 == 实例 1 == 打开一个输出流,添加一些文本,然后关闭输出流: <sample title="" desc="" lang="html" hererun="1"> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> <script> function createDoc(){ var doc=document.open("text/html","replace"); var txt="<!DOCTYPE html><html><body>学习 HTML DOM 很有趣!</body></html>"; doc.write(txt); doc.close(); } </script> </head> <body> <input type="button" value="新文档" onclick="createDoc()"> </body> </html> </sample> <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> <script> function createDoc(){ var doc=document.open("text/html","replace"); var txt="<!DOCTYPE html><html><body>学习 HTML DOM 很有趣!</body></html>"; doc.write(txt); doc.close(); } </script> </head> <body> <input type="button" value="新文档" onclick="createDoc()"> </body> </html> </run> == 实例 2 == 打开输出流 (新窗口打开; about:blank),添加文本,然后关闭输出流: <sample title="" desc="" lang="html" hererun="1"> <html> <body> <script> var w=window.open(); w.document.open(); w.document.write("<b>Hello World!</b>"); w.document.close(); </script> </body> </html> </sample> <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> <script> function createDoc(){ var w=window.open(); w.document.open(); w.document.write("<h1>Hello World!</h1>"); w.document.close(); } </script> </head> <body> <input type="button" value="新窗口的新文档" onclick="createDoc()"> </body> </html> </run> [[dom obj document|Document 对象]]
返回至“
Met doc close
”。
上一节:
Prop_doc_body
下一节:
Prop_doc_cookie