iframe onload in IE7/8 with Javascript

前端 未结 2 489
感动是毒
感动是毒 2021-01-05 14:04

I have an iframe loading into a parent page. The iframe contains a sequence of forms, and I\'d like to take action on the parent page every time the iframe content in reloa

2条回答
  •  渐次进展
    2021-01-05 14:39

    Replace:

    iframe.onload = refresh
    

    with:

    iframe.attachEvent('load', refresh, false); 
    


    To clear any confusion:

    var iframe = document.getElementById('theiframe');
    function refresh( ) {
      alert('foo');
    }
    
    if (iframe.attachEvent) iframe.attachEvent('onload', refresh);
    else iframe.addEventListener('load', refresh, false)
    

提交回复
热议问题