当前位置: 首页 > 网络学院 > 客户端脚本教程 > HTML DOM > HTML DOM open() 方法
The open() method opens a document for writing.
open()方法可以打开一个文档
If a document exists in the target it will be cleared. If this method has no arguments, a new window with about:blank is displayed.
如果目标文档已经存在那么里面的内容会被清除,如果这个方法不带内容就会显示一个新的窗口,地址栏为about:blank。
document.open("mimetype"[,replace]) |
<html>
<head>
<script>
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="打开一个新的文档并在里面写文字" onclick="createNewDoc()"> </body> </html> |
Open a new document, specify MIME type and add some text
打开一个新的文档,指定它的MIME类型并加上一些文字
评论 (0) All