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 ");
}