armm1388
armm1388

Reputation: 21

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

Upvotes: 0

Views: 3358

Answers (2)

Mauvis Ledford
Mauvis Ledford

Reputation: 42354

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.

Upvotes: 2

manojlds
manojlds

Reputation: 301177

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"

Upvotes: 2

Related Questions