Use js to determine whether the page is loaded to complete the implementation code

Source: Internet
Author: User

Use the document. onreadystatechange method to monitor status changes,
Then, use document. readyState = "complete" to determine whether the loading is complete.
The Code is as follows::
Copy codeThe Code is as follows:
Document. onreadystatechange = subSomething; // This method is executed when the page loading status changes.
Function subSomething ()
{
If (document. readyState = "complete") // when the page is loaded
Myform. submit (); // form submission
}

Five States of readyState loaded on the page
The original article is as follows:
0: (Uninitialized) the send () method has not yet been invoked.
1: (Loading) the send () method has been invoked, request in progress.
2: (Loaded) the send () method has completed, entire response received ed.
3: (Interactive) the response is being parsed.
4: (Completed) the response has been parsed, is ready for harvesting.

Translate to Chinese:
0-(not initialized) The send () method has not been called
1-(load) The send () method has been called and a request is being sent.
2-(Loading completed) The send () method is executed completely and all response content has been received
3-(interaction) parse the response content
4-(complete) The response content has been parsed and can be called on the client

Related Article

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.