title: Stop page load using javascript
body: <p>I am trying to stop the body from loading using javascript, and then write something on the body element.</p>
  
  <p>I can do this with:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script&gt;
    document.write('&lt;!--');
    window.onload = function(){
      document.body.innerHTML = "123";
    }
  &lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
      &lt;script&gt;
          alert(1); // This won't show
      &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And this works, the <code>alert</code> function will never be called.</p>
  
  <p>But the problem is that if there is another comment tag on the head section, such as:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script&gt;
    document.write('&lt;!--');
    window.onload = function(){
      document.body.innerHTML = "123";
    }
  &lt;/script&gt;
  
  &lt;!-- other tag --&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;script&gt;
          alert(1); // This will now show.
      &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>How should I handle this? It is very important that all the content on the body element, won't load. Not just hidden, but not loaded.</p>