开发者

document.write clear all controls of page

开发者 https://www.devze.com 2023-03-06 04:43 出处:网络
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 fileUse innerHTML of say a div to write.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消