源代码:
下载代码
AI 编程工具
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>菜鸟教程(runoob.com)</title> </head> <body> <h2>open() 方法</h2> <p>打开文档并删除已经存在的内容。</p> <p>打开文档并写入内容</p> <button onclick="myFunction()">点我</button> <script> function myFunction() { document.open(); document.write("<h1>Hello World</h1>"); document.close(); } </script> </body> </html>
运行结果: