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
I doubt you can attach an onload event to an iframe. It will not work on all browsers. You can on the other hand check if the iframe was loaded by:
window.onload=function()
{
var iframe=document.getElementById('myframe');
if(iframe)
alert('The iframe has just been loaded.');
}
Or use AJAX to load the content in your container. With AJAX you can set a proper load-complete event.