首页 > 技术文章 > JavaScript document open() 方法:打开一个新文档

-mrl 2018-04-28 22:07 原文

<html>
<head>
<script type="text/javascript">
function createNewDoc()
{
    var new_doc = document.open("text/html","replace");
    var txt = "<html><body>这是新的文档</body></html>";
    new_doc.write(txt);
    new_doc.close();
}
</script>
</head>
<body>
<button onclick="createNewDoc()">点击写入新文档</button>

</body>
</html>

 

推荐阅读