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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…