Script.onload=script.onreadystatechange=function ()

Source: Internet
Author: User

the role of Script.onload=script.onreadystatechange=function ():
in the code to determine whether the introduction of JS file is loaded, there is the existence of this statement, the following describes what its role.
for information on how to determine if the introduction of JS file is loaded, refer toJS How to determine whether the introduction of JS file loading is completea chapter.
The complete code is as follows:

Script.onload=script.onreadystatechange=function () {if (!this.readystate| | this.readystate== ' Loaded ' | | this.readystate== ' complete ') {//code} script.onload=script.onreadystatechange=null;}

Here's how this code works:
1.IE8 and IE8 The following browsers, the script tag does not support the OnLoad event, but supports the onreadystatechange event.
2.ie8 above browsers, Google Chrome and Mozilla Firefox support the OnLoad event.
3.readyState is a state of the onReadyStateChange event, when the value is loaded or complete, indicating that it has been loaded.
4.if (!this.readystate| | this.readystate== ' Loaded ' | | this.readystate== ' complete '),!this.readystate indicates that the following browsers are not IE11 (IE11 the following browsers also support onReadyStateChange events)

The original address is: http://www.softwhy.com/forum.php?mod=viewthread&tid=14776


Script.onload=script.onreadystatechange=function ()

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.