This article describes why you can overwrite the entire document if you call document.write after the page is loaded
I was a beginner, so I recorded it. The answer is seen in Baidu, so it is reproduced. The following answers what is the entire document will be overwritten if the document.write is called after the page is loaded. The "HTML output" in the hint refers to when the page is loaded. Code as follows: <html> <head></head> <body> <script type= "text/ JavaScript ">document.write" ("<p>Hello</p>");</script> </body> </html > When the page is loaded, you will see Hello on the page. Viewing the source file is the code above. ------------------------- But if the page is loaded and then used with document.write, the entire document will be overwritten. Code as follows: <html> <head></head> <body> <script type= "Text/javascript" > //When the mouse is clicked call document.write Document.onclick = function () { document.write ("<span> Javascript</span> "); }; </script> </body> </html> Because the mouse action is executed after the page is loaded, the entire page is covered by <span>Javascript</span>. Now look at the source file and you will see only <span>Javascript</span>.