菜单切换
FACESOHO知行者
心灵
记录
远方
赞赏工具
源代码:
点击运行
保存
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>小鸟启蒙(facesoho.com)</title> </head> <body> <script> function winTest() { var txt1 = "This is a new window."; var txt2 = "This is a test."; document.open("text/html","replace");//加上 document.writeln(txt1); document.write(txt2); document.close();//加上 } </script> <button onclick="winTest()">按钮</button> <p>解决 document.write 将整个 HTML 页面覆盖的问题</p> </body> </html>
运行结果