绝对不要在文档(DOM)加载完成之后使用 document.write()。这会覆盖该文档。
例如
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>覆盖文档</title> </head> <body> <script> document.write("首先输出"); </script> <p>请点击这</p> <br/> <input type="button" onclick="test()" value="调用函数"/> <script> function test(){ document.write("覆盖输出:"); document.write(Date()); } </script> </body> </html>
SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

更多精彩