I want to check if the iframe is loaded with the following code:
$(document).ready(function() { jQuery('#iframeID').ready(somefunction); }
It seems that 'somefunction' is called before loading the iframe (iframe is empty - just empty html-head-body).
Any idea why this is happening?
Thanks.
Try this instead.
$('#iframeID').load(function() { callback(this); });
When working with iFrames, it is enough to use the load() event instead of the $(document).ready() event.
load()
$(document).ready()
This is because you are checking if the iFrame is ready, and not inside the document.
$(document.getElementById('myframe').contentWindow.document).ready(someFunction);
gotta do the trick.
I tried:
$("#frameName").ready(function() { // Write you frame on load javascript code here } );
and it did not work for me.
this is:
$("#frameName").load( function() { //code goes here } );
Even though the event does not fire so quickly, it waits for the images and css to load.
Source: https://habr.com/ru/post/1485623/More articles:Can we enlarge the image to the full size of the device as a media player in iOS? - iosMousing over Infobox fires a hover event on the markers that stand behind it - javascriptGoogle Maps Infobox and jQuery - jqueryHow to parse contents with a specific column in a csv file in bash - bashuninstall calendar software in android - androidHow to embed m4v video file in my html page? - javascriptPassing a List from C ++ to C # - c #Split list in list by item - c #Where is the best place for event callbacks? (anonymous or named) - javascriptWhy use Perl OO simply as a method of encapsulating data? - oopAll Articles