源代码:
下载代码
AI 编程工具
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>菜鸟教程(runoob.com)</title> </head> <body> <h2>write() 方法</h2> <p>点击以下按钮,打开新窗口:</p> <button onclick="myFunction()">点我</button> <script> function myFunction() { const myWindow = window.open(); myWindow.document.write("<h1>这是一个新窗口</h1>"); myWindow.document.write("<p>Hello World!</p>"); } </script> </body> </html>
运行结果: