簡體   English   中英

為什么我的JQuery不能加載IE?

[英]Why my JQuery doesn't load on IE?

我做了這個javascript測驗: http//utbm.trunat.fr/CIP/quiz/

它適用於普通瀏覽器,但甚至不能加載Internet Explorer。

它接縫不能識別initQuiz()函數。

你知道我怎么解決這個問題嗎?

  • Internet Explorer不接受尾隨逗號:

     question = {'texte': $(this).attr("texte"), 'sound': $(this).attr("sound"),} 
  • 顯然,另一個錯誤來自這一行:

     $('title').html(QUIZ_TITLE[lang]); 

    事實證明你不能在IE中設置標題 請改用document.title = QUIZ_TITLE[lang]

  • 第三個錯誤是,你推出一個新的變量, question沒有var關鍵字,這是在IE錯誤。 你以后再做一遍,作為response 像這樣更新你的loadXML

     function loadXML(xml) { $(xml).find("question").each(function() { var question = {'texte': $(this).attr("texte"), 'sound': $(this).attr("sound")}; reponses = []; $(this).find('carre').find('reponse').each(function() { var reponse = {'texte': $(this).text(), 'sound': $(this).attr("sound"), 'bonne': false}; if($(this).attr('bonne') == "vrai") reponse['bonne'] = true; reponses.push(reponse); }); question['reponses'] = reponses; questions.push(question); }); startGame(questions); } 
  • 第四個錯誤是您驗證答案是否正確的方式。

     if($(this).attr('data-type') == 'true') 

    您將data-type屬性的值與字符串值"true" ,但是在分配值時,將其設置為布爾值true

     $('#r'+(i+1)+'input').attr('data-type', r.bonne); 

    例如,要確保始終比較字符串值,可以將值設置為:

     $('#r'+(i+1)+'input').attr('data-type', r.bonne.toString()); 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM