简体   繁体   中英

document.write clear all controls of page

document.write clear all controls of page HI' when the document.write be run, all controls in the web pages will be clear . why? In asp file

Use innerHTML of say a div to write.

<div id="iwanttowritemore"></div>

Then in JS:

document.getElementById("iwanttowritemore").innerHTML = "i can write without clearing the page"

You can't use document.write after the page has loaded, it'll replace the entire page with the contents of said function. Use something else like innerHTML if you need to insert content after the page loads. document.write is kinda frowned upon anyways.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM