Project front-end files are separated from backend development. As long as backend development updates svn front-end js files and css files are updated, a js file such as AA is referenced previously. js. to reference the jquery library in the project, if the header of each file leads them to write the jq file again, it is unlikely or difficult for them to write a new method, because they all reference this AA. js file. after JavaScript code is executed, a function automatically introduces the jq library. Therefore, the method for introducing the js file is as follows:
The Code is as follows:
GetScript: function (s, call ){
Var el = UI. DC ('script ');
If (call ){
El. onload = el. onreadystatechange = call;
}
UI. A (el, 'type', 'text/javascript ');
UI. A (el, 'src', s );
UI. GT (document, 'head') [0]. appendChild (el );
}
/* UI. DC is the creation object, UI. A is the attribute value, and GT is the abbreviation of getElementsByTagName */
So execute UI. getScript ("js/jquery/jquery-1.4.2.min.js? 1.1.23 ", function () {alert (" loaded successfully ")});
The results show that the loading is successful in IE and ff, but when I use jq in HTML, I cannot execute it in IE. I can refresh it and execute it occasionally, there are also differences between static pages on the server and on the client, but there is no problem in Firefox .........
So I thought it was not because the jq file was loaded in parallel with the html file. Before jq was loaded successfully, the HTML file was executed, so I added it at the end of the html body.
The Code is as follows:
Script
Alert ("pre-html execution ")
Script
It is found that the execution is performed before hmtl is popped up, and then the loading is successful. This is also true under Firefox. When uploading to the server, I feel that the pop-up of Firefox will appear at the same time .....
So I started to wonder how to configure it to ensure that the jq file can be executed only after it is loaded.