如何检查iframe是否已完全加载PDF文件
问题描述:
如何在iframe加载PDF文件时显示加载指示符?如何检查iframe是否已完全加载PDF文件
在我部分工作的解决方案中,我执行以下操作:当模式对话框(其中包含iframe)打开时,会显示一个加载指示符。如果iframe的内容完全加载,指示符消失并显示PDF文件。
这里是我的代码:
<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();
});
此解决方案以及在Safari,FF,Chrome和Opera但不是在IE浏览器。 我怎么能达到负载指标隐藏和PDF显示在IE中?
在谷歌我发现了一些关于onreadystatechange
和readyState
有趣的帖子,但这也行不通。
答
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.");
};
}
http://www.nczonline.net/blog/2009/09/15/iframes-onload-and-documentdomain/
[对iFrame的Load事件在IE中未烧制](的
可能重复http://*.com/questions/4334520/load-event-for-iframe-not-fired-in -ie) – 2014-10-03 21:54:09
我已经尝试从[装载事件的iFrame没有在IE中触发]接受的答案(http://*.com/questions/4334520/load-event-for-iframe-not-fired-in-ie ),但是当iframe标签被完全加载时,似乎'onload'事件属性被触发。你还有其他建议吗?我真的很困惑。 – 2014-10-03 21:59:26
你试过这个http://*.com/a/6455881/1877909 – Hitesh 2014-10-03 22:01:09