English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
write()method writes a text string to the document stream.
Note:when document.write() writes to the document stream, it is called on the loaded documentdocument.write()is automatically calleddocument.open()This will clear the document (see the 'More Examples' below).
document.write(markup)
document.write("<h2>Hello world</2>Test and see‹/›
All browsers fully support the write() method:
Method | |||||
write() | Is | Is | Is | Is | Is |
Parameter | Description |
---|---|
markup | A string containing the text to be written to the document |
Return Value: | None |
---|---|
DOM Version: | DOM 2Level |
If the document.write() method is used after the page is loaded, it will overwrite all existing content:
document.write("<p>Unique content.</p>Test and see‹/›
You can also pass comma-separated parameters:
document.write("First Argument", " Second Argument ", new Date());Test and see‹/›
DOM Document open()Methods
DOM Document writeln()Methods
DOM Document close()Methods