Say I want to bind a load event to an iframe:
var callback = function() {
};
$('iframe').one('load', callback);
This works pretty well, but I cannot be sure if the iframe is not loaded yet. In this case, the load event is already triggered and my function will never work.
How to check if iframe is loaded?
var callback = function() {
};
if(iframe already loaded) {
callback();
} else {
$('iframe').one('load', callback);
}
source
share