jquerypdfiframeloaded

Event on PDF Iframe is loaded - Javascript


Is there any easiest method to call a function right after a <iframe>, <object> or <embed> is loaded? i just want to show a preloader.gif on content load. ready() or onload() didn't help. any suggestion?

<iframe src="<?php echo $file; ?>" id="read" width="100%" height="440" border="0"></iframe>

$('#read').ready(function () {
    $('#preloader').css('display', 'none');
});

Solution

  • You can do this without using any javascript. Just wrap your iframe in some div like

    <div class="iframe-wrapper">
        <iframe src="<?php echo $file; ?>" id="read" width="100%" height="440" border="0"></iframe>
    </div>
    

    And use a CSS class to set the loading background

    .iframe-wrapper {
      background:url(../images/loader.gif) center center no-repeat;
    }