Document.write clears page

document.write() is used to write to the document stream.

In your case, the stream is most probably already closed when the onClick handler is called, because your document has finished loading.

Calling document.write() on a closed document stream automatically calls document.open(), which will clear the document.

Leave a Comment