Home > Web Front-end > JS Tutorial > document.open() and document.write()_Basic knowledge

document.open() and document.write()_Basic knowledge

WBOY
Release: 2016-05-16 19:24:45
Original
1718 people have browsed it

document.open() opens a new blank document. Under IE, open has two default parameters, which are equivalent to document.open("text/html",'""). The second parameter has only one optional value: replace, if this value is enabled, the new document will overwrite the document of the current page (equivalent to clearing all elements in the original document, and cannot go back, that is, the browser's back button is unavailable);
Look at an example :


[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute it
]

Normally I don’t write documents. open() and document.close(), because the browser will open a document before writing, and then output the content of the write to the original document. After the write is completed, there will be no close by default, otherwise the second line of document.write will overwrite the previous write.
Related labels:
and
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template