Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if iframe is loaded inside $(document).ready

I want to check if iframe is loaded with the following code:

$(document).ready(function() {
    jQuery('#iframeID').ready(somefunction);
}

It seems that 'somefunction' is called before iframe is loaded (the iframe is empty - just empty html-head-body).

Any idea why this happens?

Thank you.

like image 384
Uros K Avatar asked Jun 11 '13 13:06

Uros K


Video Answer


1 Answers

Try this instead.

$('#iframeID').load(function() {
    callback(this);
});

While dealing with iFrames, it is good enough to use load() event instead of $(document).ready() event.

like image 169
Praveen Kumar Purushothaman Avatar answered Sep 28 '22 18:09

Praveen Kumar Purushothaman