JQuery - Wait for two iframes to load

后端 未结 3 625
渐次进展
渐次进展 2020-12-21 23:14

I have a button that loads two different pages in two iframes. I need to wait for those loads to complete (like ready(), don\'t care about images and other content) and the

3条回答
  •  不知归路
    2020-12-21 23:52

    One way would be for the iFrame content to signal that it is ready. Here is a simplistic way to do this:

    Main Page

    var status = [false, false];
    
    function doneLoading(index)
    {
       status[index] = true;
       if (status[1] && status[2])
          alert("Both iframes are done loading");
    }
    

    In each iFrame

    $(document).ready(function() { parent.doneLoading(1) }); // or 2
    

提交回复
热议问题