第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

向大家請教一個IE加載JS順序問題?

向大家請教一個IE加載JS順序問題?

森林海 2018-12-06 17:36:32
我的代碼是這樣的: <!DOCTYPE html><html><head> <title>Demo</title> <meta charset="utf-8"/> <script type="text/javascript"> window.onload=function(){ var data='<html>\ <head>\ <meta charset="utf-8">\ <title>Demo</title>\ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"><\/script>\ <script type="text/javascript">\ $(function(){\ alert("abc");\ });\ <\/script>\ <\/head>\ <body>\ </body>\ </html>'; window.frames["test"].document.open(); window.frames["test"].document.write(data); window.frames["test"].document.close(); } </script></head><body> <iframe id="test" frameborder="0" name="test"></iframe></body></html> 這段代碼在Chrome、FireFox下均可以正常運(yùn)行,但在IE下第一次運(yùn)行會提示$未定義,但刷新后有時又可以正常彈出"abc",所以猜測是運(yùn)行到alert("abc")這段代碼時IE還沒有加載完jquery代碼。 向大家請教解決方案,通過修改: $(function(){\ alert("abc");\});\ 這一部分,讓代碼在IE789上可以正常運(yùn)行,謝謝!
查看完整描述

4 回答

?
精慕HU

TA貢獻(xiàn)1845條經(jīng)驗(yàn) 獲得超8個贊

這里提供一種方法,但在FireFox下好像有些問題,會彈出兩次:

<!DOCTYPE html>
<html>
<head>
<title>Demo</title>
<meta charset="utf-8"/>
<script type="text/javascript">
window.onload
=function(){
var data='<html>'+
' <head>'+
' <meta charset="utf-8">'+
' <title>Demo</title>'+
' <script type="text/javascript">'+
' function load_script(url, callback) { '+
' var script = document.createElement("script"); '+
' script.type = "text/javascript"; '+
' if (script.readyState) { '+
' script.onreadystatechange = function() { '+
' if (script.readyState == "loaded" ||script.readyState == "complete") { '+
' script.onreadystatechange = null; '+
' callback(); '+
' } '+
' } '+
' } else { '+
' script.onload = function() { '+
' callback(); '+
' } '+
' } '+
' script.src = url; '+
' document.getElementsByTagName("head")[0].appendChild(script); '+
' }'+
' load_script("http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js",function(){'+
' $(function(){'+
' alert("abc");'+
' });'+
' });'+
' <\/script>'+
' <\/head>'+
'<body>'+
'</body>'+
'</html>';
window.frames[
"test"].document.open();
window.frames[
"test"].document.write(data);
window.frames[
"test"].document.close();
}
</script>
</head>
<body>
<iframe id="test" frameborder="0" name="test"></iframe>
</body>
</html>
查看完整回答
反對 回復(fù) 2018-12-24
?
皈依舞

TA貢獻(xiàn)1851條經(jīng)驗(yàn) 獲得超3個贊

樓主可以用fidller去查看下加載順序,以及時間,自然能夠看出個所以燃來

查看完整回答
反對 回復(fù) 2018-12-24
?
喵喵時光機(jī)

TA貢獻(xiàn)1846條經(jīng)驗(yàn) 獲得超7個贊

mark..

查看完整回答
反對 回復(fù) 2018-12-24
  • 4 回答
  • 0 關(guān)注
  • 600 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號