title: Why document.write() behaves differently in Firefox and chrome?
body: <p>I am making a simple Redirect script that will redirect users to <code>2.html</code> after 5 seconds.</p>
  
  <p>When I tested the script on Chrome and it works!, But in latest Firefox but it doesn't decrease seconds and hangs.</p>
  
  <p>I am a beginner and have tried my best out of knowledge but I am unable to solve this, I looked online but was unable to find a solution. How can I solve this?</p>
  
  <p>My code:</p>
  
  <p>index.html:</p>
  
  <pre><code>&lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;My First Page&lt;/title&gt;
      &lt;script type="text/javascript" src="script.js"&gt;&lt;/script&gt;
    &lt;/head&gt;
  
    &lt;body&gt;
  
          &lt;input type="button" value=" YES " onclick="yes()" /&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <hr>
  
  <p>script.js:</p>
  
  <pre><code>c=5;
  function yes() {
      alert("Right");
      var ans=0;
      while(ans==0){
          var x=prompt("Your Name?");
          var ans=confirm("Your Name is "+x+" right?");
      }
      document.write('&lt;h1&gt;Welcome '+x+' &lt;/h1&gt;&lt;p id="show"&gt;You are being redirected in 3 seconds&lt;/p&gt;');
      function updateShow(){
              document.getElementById('show').innerHTML="&lt;h1&gt;You are being redirected in "+c+"     seconds&lt;/h1&gt;";
              c=c-1;
              if(c&lt;0){
                  document.location='2.html';
              }
              else{
                   setTimeout(function(){ updateShow(); },1000);
                   }
  
      }
      var iAmTimer= setTimeout(function(){ updateShow(); },1000);
  } 
  </code></pre>
  
  <hr>
  
  <p>2.html:</p>
  
  <pre><code>&lt;html&gt;
    &lt;body&gt;
      &lt;h1&gt;Welcome&lt;/h1&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <hr>
  
  <p><strong>Console Error Messages</strong></p>
  
  <ol>
  <li>Firefox - None</li>
  <li>Chrome - None</li>
  </ol>
  
  <hr>
  
  <p><strong>Output</strong>:  </p>
  
  <ol>
  <li><p>Firefox (forever): </p>
  
  <pre><code>Welcome &lt;name&gt;
  
  You are being redirected in 3 seconds 
  </code></pre></li>
  </ol>
  
    <hr>
  
  <ol start="2">
  <li><p>Chrome:</p>
  
  <pre><code>Welcome &lt;name&gt;
  
  You are being redirected in 3 seconds
  
  Welcome &lt;name&gt;
  
  You are being redirected in 2 seconds
  
  Welcome &lt;name&gt;
  
  You are being redirected in 1 seconds
  
  Welcome &lt;name&gt;
  
  You are being redirected in 0 seconds
  </code></pre></li>
  </ol>
  
  <p>Any help is appreciated.</p>