1<html> 2<head> 3<script type="text/javascript"> 4function createNewDoc() 5{ 6 var new_doc = document.open("text/html","replace"); 7 var txt = "<html><body>这是新的文档</body></html>"; 8 new_doc.write(txt); 9 new_doc.close(); 10} 11</script> 12</head> 13<body> 14<button onclick="createNewDoc()">点击写入新文档</button> 15 16</body> 17</html>
JavaScript document open() 方法:打开一个新文档
Stella981
2021-10-11
1062 0 0
点赞
收藏
评论区
加载中...