Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/412.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JavaScript在Firefox中持续运行_Javascript_Firefox - Fatal编程技术网

JavaScript在Firefox中持续运行

JavaScript在Firefox中持续运行,javascript,firefox,Javascript,Firefox,我不明白为什么我的代码会继续运行,即使它似乎已经完全加载了正确的HTML。这个问题只出现在Firefox(使用版本3.5.3)中,而不出现在IE中。这只是一个显示乘法表的简单脚本,其中混合了一些装饰效果 <html> <head> <title>Multiplication Table</title> <script> function drawTable(){ var rb = docu

我不明白为什么我的代码会继续运行,即使它似乎已经完全加载了正确的HTML。这个问题只出现在Firefox(使用版本3.5.3)中,而不出现在IE中。这只是一个显示乘法表的简单脚本,其中混合了一些装饰效果

<html>
  <head>
    <title>Multiplication Table</title>
    <script>
      function drawTable(){
        var rb = document.configForm.rowBegin.value - 1;
        var re = document.configForm.rowEnd.value;
        var cb = document.configForm.colBegin.value - 1;
        var ce = document.configForm.colEnd.value;
        document.write("Perfect squares are highlighted in red.<p>");
        document.write("<table border=\"1\">");
        for(i = rb; i <= re; i++){
          document.write("<tr>");
          for(j = cb; j <= ce; j++){
            if(i == rb && j == cb){
            // ignore top left corner
              document.write("<td bgcolor=\"#ffffff\"></td>");
            }
            else if(i == rb){
            // to display the column headers
              if(j % 2 == 0)
                document.write("<td align=\"center\" bgcolor=\"#99d9e0\">" + j + "</td>");
              else
                document.write("<td align=\"center\">" + j + "</td>");
            }
            else if(j == cb){
            // to display the row headers
              if(j % 2 == 0)
                document.write("<td align=\"center\" bgcolor=\"#99d9e0\">" + i + "</td>");
              else
                document.write("<td align=\"center\">" + i + "</td>");
            }
            else{
            // writes the solutions to the table
              if(i == j || Math.sqrt(i*j) % 1 == 0)
              // highlight the perfect squares
                document.write("<td align=\"center\" bgcolor=\"#ff8080\">" + i * j + "</td>");
              else if(j % 2 == 0)
                document.write("<td align=\"center\" bgcolor=\"#99d9e0\">" + i * j + "</td>");
              else
                document.write("<td align=\"center\">" + i * j + "</td>");
            }
          }
          document.write("</tr>");
        }
        document.write("</table>");
      }
    </script>
  </head>
  <body>
    <h2>Multiplication Table</h2>
    <form name="configForm">
      Row Range:</br>
        Begin&nbsp;<input type="text" name="rowBegin" size="5">
        End&nbsp;<input type="text" name="rowEnd" size="5">
      <p>
      Column Range:</br>
        Begin&nbsp;<input type="text" name="colBegin" size="5">
        End&nbsp;<input type="text" name="colEnd" size="5">
      <p>
      <input type="Submit" value="Make Table" onclick="return drawTable()">
    </form>
  </body>
</html>

乘法表
函数drawTable(){
var rb=document.configForm.rowBegin.value-1;
var re=document.configForm.rowEnd.value;
var cb=document.configForm.colBegin.value-1;
var ce=document.configForm.colEnd.value;
记录。写下(“完美的正方形以红色突出显示。”;
文件。填写(“”);
对于(i=rb;i如果使用document.write(),则需要使用document.close();来告诉浏览器您已经完成了

使用类似alert();的功能也可以阻止微调器旋转,但这可能不是您想要的。

在函数末尾添加
document.close();
。Firefox似乎没有意识到您已经完成了编写