DEV Community

Discussion on: JavaScript: Problem with document.write

Collapse
 
joekrump profile image
Joe Krump

write() will do what you described as noted at the top of the documentation for the method which is found here: developer.mozilla.org/en-US/docs/W...

"[C]alling document.write on a closed (loaded) document automatically calls document.open, which will clear the document."

I'm also curious to know what it is you are trying to do. Maybe append() is what you're looking for.

Collapse
 
andybullet profile image
AndyBullet

This message appears Uncaught DOMException: Failed to execute 'append' on 'Document': Nodes of type '#text' may not be inserted inside nodes of type '#document'.