document.write can be used to emit markup during the parsing of the page. It cannot be used for modifying the page after it's parsed. The output of document.write goes straight into the parser as though it had been in the HTML document in the first place. So for instance:
<body> <script> document.write("<p>"); </script> hi there</p>
looks exactly the same to the browser as
<body> <p>hi there</p>
innerHTML, which is not a function but rather a property, exists on all DOM element instances, and can be used to set their content, using markup. This, along with the various DOM methods available on instances, is the primary way that dynamic web pages are done. For example:
<body> <p id="target">Hi there</p> <script> document.getElementById("target").innerHTML = "Updated by <strong>code</strong>"; </script> </body>
...changes the paragraph from saying "hi there" to saying "Updated by code".
innerHTML可以重绘页面的一部分。