Asynchronous JS testing in IE

Source: Internet
Author: User

Test.html:

<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html>
<Head id = "head">
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> test </title>
<Style type = 'text/css '>
Img
{
Border: 1px solid red;
Display: block;
Height: 50px;
Width: 50px;
}
</Style>

<Script type = 'text/javascript '>
// Because some functions need to pass parameters, the parameters are included.
Function Exec (funcName, arr ){
If (typeof funcName = "string ")
{
// If this function has been loaded
If (window [funcName]) {
Window [funcName] (arr );
} // If the function is not loaded, check every 0.1 seconds until the loading is complete.
Else {
Window. setTimeout (function () {Exec (funcName, arr)}, 1000 );
}
} Else
{
FuncName (arr );
}
}
// You can call Exec (window. fun | "fun", [456]) like this;

Function AppendJS (src, func ){

Var script = document. createElement ("script ");
Script. type = "text/javascript ";
Script. src = src;
If (script. readyState ){

Script. onreadystatechange = function (){
If (this. readyState = "loaded" | this. readyState = "complete "){

If (func ){
Func ();
}
}
};
} Else {
If (func ){
Script. onload = func;
}
}
Document. getElementById ('head'). appendChild (script );

}
AppendJS ("jquery-1.4.2.min.js", function (){
// Fuck (); the probability of this error is very high, because the jquery-1.4.2.min.js load is completed, but 1. js may not be loaded, so the Fuck function may not be defined
Exec (window. Fuck | "Fuck"); // No error will be reported because of the judgment.
});
AppendJS ("1.js", null );
</Script>
</Head>
<Body id = "bd">
<Div id = "dd">
</Div>
</Body>
</Html>

1. js is as follows:
For (var I = 0; I <2000000; I ++ ){
}
For (var I = 0; I <1000000; I ++ ){
}

For (var I = 0; I <100000; I ++ ){
}

Function Fuck (){
Alert ("fuck ");
}

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.