「オンデマンド」の要件では、スクリプトがロードされた場合、コールバック関数が返されることをしばしば判断します。
オンロードを使用して、ロードされたJSオブジェクト(Js.Onload)を判断できます。 Curveは国を保存します-IE6、IE7は、Js.ReadeyStateChangeを使用して各状態の変更を追跡できます(通常、ロード、インタラクティブ、完全な場合、荷重が完了し、荷重が完了します)。コールバック機能が返されます。
ReadyStateステータスには補足ノートが必要です。
1。インタラクティブな状態では、ユーザーは相互作用に参加できます。
2。オペラは実際にJs.ReadedStateChangeをサポートしていますが、そのステータスはIEのステータスとは大きく異なります。
コードコピーは次のとおりです。
<スクリプト>
関数include_js(file){
var _doc = document.getElementsByTagname( 'head')[0];
var js = document.createelement( 'script');
js.SetAttribute( 'type'、 'text/javascript');
Js.SetAttribute( 'Src'、file);
_DOC.AppendChild(JS);
if(!/*@cc_on!@*/0){//そうでない場合
// firefox2、firefox3、safari3.1+、opera9.6+ support Js.onload
js.onload = function(){
alert( 'firefox2、firefox3、safari3.1+、opera9.6+ support Js.onload');
}
} それ以外 {
// IE6、IE7サポートJs.onreadystatechange
js.onreadystatechange = function(){
if(js.readystate == 'loaded' || js.readystate == 'complete'){
alert( 'ie6、ie7サポートJs.onreadystatechange');
}
}
}
falseを返します。
}
include_js( 'http://www.planabc.net/wp-includes/js/jquery/jquery.js');
</script>