I have created a iframe dynamically and added a src attribute to it. Then I have appended this iframe to body of the page. Know I want to attach an onload event to iframe to read the iframe content. Can somebody suggest how do I do that?
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. }