Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

$(document).ready and iframe content [duplicate]

Will

$(document).ready 

in parent page wait for iframe content to be loaded completely?

I have a parent page in which there is a an iFrame. After the iFrame is completely loaded I need to invoke a function in the iFrame from the parent page.

like image 213
rahul Avatar asked Jul 25 '09 12:07

rahul


2 Answers

See jQuery .ready in a dynamically inserted iframe

like image 114
Sean A.O. Harney Avatar answered Oct 06 '22 05:10

Sean A.O. Harney


I've been the whole day breaking my balls to find this, I needed it for the work.

Finally I've made my thing (A website with an iframe that loads the content of the links. All i wanted to do was to scroll the page to the top, with a button inside the iframe And it seemed to be wizards work)

Well, that's what I did:

$(document).ready(function () {
 $('ifram#IframeID').load(function () { //The function below executes once the iframe has finished loading<---true dat, althoug Is coppypasta from I don't know where
     var varStoresNameIframe =$('iframe#IframeID').contents().find('.buttonsClass');
        $(varStoresNameIframe).click (function () {
            $('html , body').animate({ scrollTop: 0 }, 'slow'); 
        }); 
   });
});

Related link:

  • jQuery’s document ready() event and iframe

So the masterkey for me was the line:

$('ifram#IframeID').load(function () {
like image 25
user954728 Avatar answered Oct 06 '22 06:10

user954728