title: Document.write method questions
body: <p>I'm experimenting with write method &amp; onload event. Here is my code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
      &lt;/head&gt;
      &lt;body onload="document.write('body loaded!')"&gt;
          &lt;h1&gt;Hello World!&lt;/h1&gt;
          &lt;img onload="document.write('img loadeld!')" src="smiley.gif" alt="Smiley face" width="42" height="42" /&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>If i run this in browser it outputs "img loadeld" and just "hangs", seems to be loading the page infinitely.
  I expected the browser outputs "img loadeld" and then as the body element is ready
  "body loaded" and just stops as normally.</p>
  
  <p>My questions:</p>
  
  <ol>
  <li>Why is there such a hang? Why the onload event on img element blocks the browser from continuing &amp; rendering "body loaded"?</li>
  <li>Why if i remove onload handler from img element the reponse is as expected - "body loaded"
  and the page isn't blocked. </li>
  </ol>