You can only use document.write in HTML output. If you use this method after the document is loaded, the entire document is overwritten. __html

Source: Internet
Author: User
JavaScript can only use document.write in the HTML output stream, which is used when the document is loaded (for example, in a function) and overwrites the entire document. HTML output stream: The current data form is HTML-formatted data that is being exported, transmitted, or displayed, so it is called a "stream." thinking: What is used in HTML output, and what is used after the document is loaded.

The reference code is as follows:

<! DOCTYPE html>

Example code execution to document.write to write to the page, the document load complete, but did not call the function, so will not execute document.write in the function, when the click button, triggered the event, is the document after the completion of the load is used document.write, will overwrite the original letter in the page Interest.
code written in JavaScript can only be executed through a html/xhtml document, one line at a line, and the document is actually loaded while loading and writing content to the screen with document.write, and when the load is complete, document closes. If you call document.write to write on the page again, the document will be rewritten.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.