var head = document.getElementsByTagName("head")[0] || document.documentElement;var script = document.createElement("script");if ( s.scriptCharset ) { script.charset = s.scriptCharset;}script.src = s.url;// Handle Script loading var done = false;// Attach handlers for all browsersscript.onload = script.onreadystatechange = function() { if ( !done && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { done = true; jQuery.handleSuccess( s, xhr, status, data ); jQuery.handleComplete( s, xhr, status, data ); // Handle memory leak in IE script.onload = script.onreadystatechange = null; if ( head && script.parentNode ) { head.removeChild( script ); } }};// Use insertBefore instead of appendChild to circumvent an IE6 bug.// This arises when a base node is used (#2709 and #4378).head.insertBefore( script, head.firstChild );
參考:http://stackoverflow.com/questions/4845762/onload-handler-for-script-tag-in-internet-explorernode