title: Dynamically create an iframe and attach onload event to it
body: <p>I have created a iframe dynamically and added a <code>src</code> attribute to it. Then I have appended this iframe to body of the page. Know I want to attach an <code>onload</code> event to iframe to read the iframe content. Can somebody suggest how do I do that?</p>
  
  <pre><code>frame = document.createElement('iframe');
  frame.setAttribute('src','http://example.com');
  body.appendChild(frame);
  frame.onload = function(){
      alert('hi'); // here I want to read the content in the frame.
  }
  </code></pre>