JS 在 Chrome 中工作,但在 Firefox 中不工作

JS working in Chrome but not Firefox

这个脚本几周前在 FireFox 中停止工作,大约在我向网站添加 SSL 证书的时候。我已经确认到处都在使用 SSL,并且我尝试禁用所有最近安装的插件,但无济于事。

我已经使用 Web 控制台查看了它,也没有看到任何错误 - 尽管我对此不是很有经验。

我还查看了其他关于 js 在 Chrome 但不是 FF 中工作的线程,但是 none 提议的解决方案似乎适用于我的脚本。

问题是 js 显然根本没有被调用 - 它应该出现在介绍和 "share" 图形之间。

有什么想法吗?

这是它应该显示的页面,在文本和 "share" 图形之间:Quiz

这是 js 文件:Javascript

代码如下:

$.each(questions, function (key, value) { 
//console.log( key + ": " + value.question );        question = value.question;
    qtype = value.qtype;
    opts = value.opts;
    answer = value.answer;
    special = value.special;        $('#quiz-form').append('<p>&#160;<br>' + parseInt(key + 1) + ") " + question + '</p>');        if (qtype == "radio")
{       opt_array = opts.split(',');       for (i = 0; i < opt_array.length; i++)
{      $('#quiz-form').append('<p><input data-ftype="radio" type="radio" name="question_' + key + '" class="question_' + key + '" value="' + opt_array[i] + '"> ' + opt_array[i] + ' </p>');           }
} else if (qtype == "checkbox"}
else if (qtype == "checkbox")
{
   opt_array = opts.split(',');
   for (i = 0; i<opt_array.length;i++)
{
    $('#quiz-form').append('<p><input data-ftype="checkbox" type="checkbox" name="question_' + key + '" class="question_' + key + '" value="'+ opt_array[i] + '"> ' + opt_array[i] + '</p>');
}
}
    else if (qtype == "input")
{

    $('#quiz-form').append('<p><input data-ftype="text" name="question_' + key + '" type="text" class="question_' + key + '" value="" style = "border:1px solid"  ></p>');
}        $('#quiz-form').append('<p><input name="answer_' + key + '" type="hidden" value="' + answer + '" class="answer_' + key + '"   ></p>');
    $('#quiz-form').append('<p class="special" id="special_' + key + '" ><strong>Correct answer(s): ' + answer + '</strong> » Explanation: ' + special + '</p>');
});
    $('#quiz-form').append('<p>All done? Check your answers: <input name="submit" id="submit" type="button" value="Submit"></p>');        $('#quiz-form').append('<p>Want another chance? <input name="refresh" id="refresh" type="button" value="Start over"></p>');        $( "#quiz-form" ).on( "click", "#submit", function() {


quest_numb = questions.length;

user_answers = new Array();
real_answers = new Array();   
for (i = 0; i <quest_numb;i++) 

{

if ($("input[name ='question_" + i + "']").data('ftype')=='radio')     {       user_answers.push($(":input[type='radio'][name ='question_" + i + "']:checked").val());      }      if ($("input[name ='question_" + i + "']").data('ftype')=='text') {       user_answers.push($(":input[type='text'][name ='question_" + i + "']").val());      }      if ($("input[name ='question_" + i + "']").data('ftype')=='checkbox') {
  var chkArray = [];
     $(".question_" + i + ":checked").each(function() {
  chkArray.push($(this).val());
 });   var selected = chkArray.join(',')
 user_answers.push(selected);      }        real_answers.push($(":input[type='hidden'][name ='answer_" + i + "']").val());      // alert($(":input[type='text'][name ='question_"+i+"']").val());

 }

 points=0;
 message='<div id="results">';
 inc=1;
 for(i=0;i<real_answers.length;i++) {
 if (typeof user_answers[i]=='undefined' || user_answers[i]=='') 
{   //message+='<p>'+parseInt(i+1) + ')' +' You didn't answer this     question.</p>';
  $('#special_'+i).text(i+inc+') '+'You didn\'t answer this question.');
  $('#special_'+i).show();
  $(":input[name ='question_"+i+"']").prop('disabled',true);
 }

  else if( user_answers[i].toLowerCase().trim()==real_answers[i]) 
  {


points++;
//message+='<p>' +parseInt(i+1)  + ')' +' Très bien !</p>';
$('#special_'+i).text(i+inc+') '+'Très bien !');
  $('#special_'+i).addClass('correct');
  $('#special_'+i).show();

 }   else 
 {

  $('#special_'+i).text($('#special_'+i).text().replace(i+inc+') '+' ',''));
  $('#special_'+i).prepend(i+inc+') '+' ');
  $('#special_'+i).show();
 }

 }
 message+='<p> Your score: ' + points + '/' + real_answers.length + '</p>';percent=points*100/real_answers.length;if(percent>=90) 
 {
   message+='<p> Chapeau !</p>';

 }
 if(percent>=80 && percent<90) 
 {
 message+='<p> Très bien !</p>';

 }if(percent>=60 && percent<80) 
 {
 message+='<p> Pas mal.</p>';

 }if(percent>=40 && percent<60) 
 {
 message+='<p> Houp ! Il faut étudier un peu plus.</p>';

 }
 if(percent<40) 
 {
   message+='<p> Oh là là - il faut étudier !</p>';

}message+='</div>';
    $('#quiz-form #results').remove();
    $('#quiz-form').prepend(message);
$("html, body").animate({ scrollTop: 0 }, "slow");

 });
    $( "#quiz-form" ).on( "click", "#refresh", function() {
 location.reload();
 window.scrollTo(0,0);
 });
});function getQueryVariable(variable)
{
       var query = window.location.search.substring(1);
   var vars = query.split("&");
   for (var i = 0; i<vars.length;i++) {
           var pair = vars[i].split("=");
           if (pair[0] == variable){return pair[1];}
   }
       return(false);
 }

您的代码中出现了大量 JS 错误。首先,您需要修复不安全的文件引用,因为您使用的是 SSL,因此不会加载这样的文件 - 将其更改为相对路径或将 http 替换为 https:

<script src="http://www.feedblitz.com/js/tinybox2/tinybox.js" type="text/javascript">

如果您不确定如何在浏览器中查看这些错误,请参阅以下任何一篇文章:

https://developer.chrome.com/devtools https://developer.mozilla.org/en/docs/Tools/Web_Console