[英]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.