在iframe中加载pdf时,iframe未触发加载事件

Load event not firing in iframe while loading pdf in iframe

本文关键字:加载 iframe 事件 pdf      更新时间:2023-09-26

这是我的HTML:-

<iframe src="Dyanamicallygeneratedpath" id="iPrintform" name="iPrintform"  class="iframeDisable" scrolling="auto" height="600" width="650" style="display:block;"></iframe>

Jquery:-

第一次尝试:-

var iFrame = $('#iPrintform');
iFrame.bind('load', function () { //binds the event
alert('iFrame Reloaded');
});

第二次尝试:-

$("#iPrintform").on("load", function () {
alert("Iframe loaded");
});

我尝试将load事件、onready事件绑定到iframe,但chrome没有任何作用。

尝试实现以下代码。

var iframeID = $('#iPrintform').contents();
    iframeID.find("addevents").click(function(){
       alert("working");
    });

等待iframe加载,然后通过iframe的contentWindow.document 进行绑定

 var xiframe = $('iframe')[0];
 iframe.onload = function(){
   // log("iframe loaded");
   $(xiframe.contentWindow.document)
    .bind(function(){ ... });
    $(xiframe.contentWindow.body).addClass('..');
    };