javascript - load event for iframe does not fire in IE -
i've created iframe
in page here it's code:
var frame = document.createelement('iframe'); frame.setattribute('src',''); document.body.appendchild(frame); if(document.addeventlistener){ frame.addeventlistener('load', callback, false); } else { frame.attachevent('onload', callback); } function callback(){ alert('test'); }
it works fine in ff no thing alerted in ie, why?
note use ie10 in win8
you need move document.body.appendchild()
after addeventlistener()
call
var frame = document.createelement('iframe'); frame.setattribute('src',''); if(frame.addeventlistener){ frame.addeventlistener('load', callback, true); } else { frame.attachevent('onload', callback); } document.body.appendchild(frame); function callback(){ alert('test'); }
Comments
Post a Comment