I had problem with iframe that was loading a document using google document viewer, sometimes the document would not load.
I used this solution to check if iframe is successfully loaded, or if it should be reloaded.
The solution works great on pc(chrome), but on iphone(safari) $('#iframe').on('load', ...) event triggers even when there is no content.
On pc on load event is only triggered when iframe is trully loaded and has content.
function reloadIFrame() {
document.getElementById("ifm").src=document.getElementById("ifm").src;
}
ints.push( setInterval("reloadIFrame();", 2000));
$( document ).ready(function() {
$('#ifm').on('load', function() {
// this event fires even when there is no content on safari
// ....stop reloading the iframe etc.....
alert($('#ifm').attr('src')); // this gives me correct url, even when not loaded
Iframe:
<iframe data-iframe="true" id="ifm" data-ext="<?php echo $ext ?>"
class="document-iframe"
src="<?php echo $full_src ?>" data-tool-id="<?php echo $tool->ID ?>">
</iframe>