iFrame src change event detection?

前端 未结 7 1308
夕颜
夕颜 2020-11-22 08:02

Assuming I have no control over the content in the iframe, is there any way that I can detect a src change in it via the parent page? Some sort of onload maybe?

My l

7条回答
  •  粉色の甜心
    2020-11-22 08:40

    Answer based on JQuery < 3

    $('#iframeid').load(function(){
        alert('frame has (re)loaded');
    });
    

    As mentioned by subharb, as from JQuery 3.0 this needs to be changed to:

    $('#iframe').on('load', function() {
        alert('frame has (re)loaded ');
    });
    

    https://jquery.com/upgrade-guide/3.0/#breaking-change-load-unload-and-error-removed

提交回复
热议问题