Use JS to determine whether the page is loaded to complete the basic knowledge of code _

Source: Internet
Author: User
Using the Document.onreadystatechange method to monitor state changes,
Then use document.readystate = = "complete" to determine whether the load completed
The code is as follows
Copy Code code as follows:

Document.onreadystatechange = subsomething;//Executes this method when the page load state changes.
function subsomething ()
{
if (document.readystate = = "complete")//when page loads state
Myform.submit (); Form submission
}

five states of page load ReadyState
The original text reads as follows:
0: (uninitialized) the Send () method has not yet been invoked.
1: (Loading) the Send () method has been invoked and request in progress.
2: (Loaded) the Send () method has completed, entire response received.
3: (Interactive) The response is being parsed.
4: (Completed) The response has been parsed, is ready for harvesting.

translated into Chinese as:
0-(uninitialized) the Send () method has not been called
1-(load) called Send () method, sending request
2-(load complete) Send () method completed, received all response content
3-(interactive) parsing response content
4-(complete) The response content resolution is complete and can be invoked on the client

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.