<HTML>
Chrome performance in case of success or failure:
Document is initialized before the engine starts parsing the code. It is put into the scope and pushed to the end of the scope chain. However, the scope chain is empty at this time, so the document is at the top, that is, what we call global variables.
Initialization is similar to VaR document = new document ();
Document is a class with methods such as body, getelementbyid, getelementsbyname, and write.
Therefore, document has the prototype method of document and its member variables, but getelementbyid can only be used after the body has been loaded. This is why when the page is not loaded, we cannot use getelementbyid, but write does not, so we can call document before the page is loaded. write Method
We also know that the write method is used to specify the output of the object in the current document,
In fact, when the document. Write method is called, the open and close methods are called.
Document. open ();
Document. Write ();
Document. Close ();
When open is enabled, a document stream is opened to input the content. When the document already exists, it is cleared first.
Write is the written content, close is the closing of the Document Stream
In the preceding example, when document. when writing, the document does not exist, so it will not empty, but will directly attach the content to the Document Stream. When there is content appended to the document stream, the body will naturally be created. You can use the firebug breakpoint to clearly see the first document. the body is null before write, when document. after the write operation, the body will be "body". If it is a space or other elements, no body will be created, so the author resolves the document. you can use document. body. appendchild
However, we also remind you not to use document. Write unless necessary, because when window. onload is used, the document will be cleared.