iframe onload in IE7/8 with Javascript

前端 未结 2 462
感动是毒
感动是毒 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:29

    You can call it from the iframe by calling parent.refresh() when you are done with a submit.

    0 讨论(0)
  • 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)
    
    0 讨论(0)
提交回复
热议问题