The Document. write() method adds a string of text to a document stream that has been opened by document. open(). Because document.write() writes to the document stream, document.write() is called.