Arerrac
Arerrac

Reputation: 419

Pass document.ready() of iframe to parent container

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!

Upvotes: 0

Views: 623

Answers (2)

Arerrac
Arerrac

Reputation: 419

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);
});

Upvotes: 0

Jan Hommes
Jan Hommes

Reputation: 5152

$('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.

Upvotes: 0

Related Questions