Javascript 如何检查iframe是否已完全加载PDF文件
iframe加载PDF文件时,如何显示加载指示器 在部分工作的解决方案中,我执行以下操作:当打开模式对话框(其中包含iframe)时,会出现一个加载指示器。如果iframe的内容已完全加载,则指示器将消失,并显示PDF文件 这是我的密码:Javascript 如何检查iframe是否已完全加载PDF文件,javascript,jquery,internet-explorer,iframe,cross-browser,Javascript,Jquery,Internet Explorer,Iframe,Cross Browser,iframe加载PDF文件时,如何显示加载指示器 在部分工作的解决方案中,我执行以下操作:当打开模式对话框(其中包含iframe)时,会出现一个加载指示器。如果iframe的内容已完全加载,则指示器将消失,并显示PDF文件 这是我的密码: <div data-gid="<?php echo $gid; ?>" class="modal fade" id="sammelPDF" tabindex="-1" role="dialog" aria-labelledby="sammel
<div data-gid="<?php echo $gid; ?>" class="modal fade" id="sammelPDF" tabindex="-1" role="dialog" aria-labelledby="sammelPDF" aria-hidden="true">
<div class="modal-dialog" style="width: 1000px;">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Wettkampfplan gesamt</h4>
</div>
<div class="planGesamtModalBody modal-body">
<div class="rwk-progress" style="display: table; margin: 0 auto;">
<div style="text-align: center;">
<img src="/planung/images/spinner.gif" />
</div>
<p style="margin-top: 10px; text-align: center;">Bitte haben Sie etwas Geduld...</p>
</div>
<iframe width="100%" height="100%" frameborder="0" allowtransparency="true" id="planGesamtPDFFrame" src=""></iframe>
</div>
</div>
</div>
</div>
$('.sammelPDFWettkampfplan').click(function() {
$('.planGesamtPDFFrame').hide();
$('.rwk-progress').show();
});
$('#sammelPDF').on('show.bs.modal', function() {
var group = getActiveTab();
var url = '/pdf?gid=' + $(this).data('gid') + '&classes=1,2,3,4&group=' + group.attr('id') + '&nocache=' + new Date().getTime();
$('#planGesamtPDFFrame').attr('src', url);
});
$('#planGesamtPDFFrame').load(function() {
$('.rwk-progress').hide();
$(this).show();
});
可能重复的我已经尝试了接受的答案,但是当iframe标记完全加载时,onload
事件属性似乎被触发。你还有别的想法吗?我真的很困惑。你试过了吗?我刚试过你的解决方案,但它对我也不起作用:(我刚试过你的解决方案,但它不起作用:(当我用iframe.addEventListener
添加时,如果使用iframe.addEventListener
,则选择了此分支,但似乎没有执行事件的回调方法。
var iframe = document.createElement("iframe");
iframe.src = "simpleinner.htm";
if (iframe.attachEvent){
iframe.attachEvent("onload", function(){
alert("Local iframe is now loaded.");
});
} else {
iframe.onload = function(){
alert("Local iframe is now loaded.");
};
}