How can I clear or refresh the page in the browser using javascript? I have a loop that prints a string to the page each second and I want to clear the screen each time it updates.
How can I clear or refresh the page in the browser using javascript? I have a loop that prints a string to the page each second and I want to clear the screen each time it updates.
Share Improve this question edited Mar 5, 2014 at 7:51 iKlsR asked Apr 1, 2012 at 19:23 iKlsRiKlsR 2,6726 gold badges29 silver badges46 bronze badges 02 Answers
Reset to default 11If you append your string to the document body, you can just use
document.body.innerHTML = "";
You may choose to write it like this
document.write(‘ ‘)