0

Is there a way to pass the document.ready() of an iframe to the parent container?

My scenario is this:

External content is shown in an iframe in a Shadowbox. The shadowbox overlay (#sb-overlay) has a background with a loading icon. I now would like to remove the loading icon, when the content in the iframe has completely loaded.

Thanks!

urbz
  • 2,663
  • 1
  • 19
  • 29
Arerrac
  • 409
  • 1
  • 5
  • 18
  • I think youre answer is here : http://stackoverflow.com/questions/12267010/how-can-i-detect-whether-an-iframe-is-loaded – BastienSander Jun 12 '14 at 11:25

2 Answers2

0
$('iframe#iframeid').load(function() {
    //hide the loading
});

According to this post, for iframes the load event is good enough. No need to implement document.ready.

Community
  • 1
  • 1
Jan Hommes
  • 5,122
  • 4
  • 33
  • 45
0

Here's the code, that got it working for me:

$('.iframelink').on('click', function(){
    setTimeout(function(){
        $('iframe').load(function(){
            $('#sb-overlay').css('background-image','none');
            console.log('loaded');
        });
    }, 1000);
});
Arerrac
  • 409
  • 1
  • 5
  • 18