Friday, October 12, 2007

How to "clear screen" in javascript

I wanted to clear an HTML page after clicking a button. So how do I do it in javascript? I wanted something simple like the "cls" command that exists in several programming languages (including the "cls" command in the windows command prompt).

After a simple google search I found two options that I liked in the thescripts.com forum:

location.replace("about:blank")

or

document.body.innerHTML=""

I prefer the second option because I can insert what I want in the innerHTML property.

Post a Comment