[英]How could I check if an iframe have completely loaded a PDF file
How could I show a loading indicator while an iframe is loading a PDF file? 当iframe加载PDF文件时,如何显示加载指示符?
In my partially working solution I do the following: When the modal dialog, where the iframe is in it, is opened then an loading indicator appears. 在我的部分工作解决方案中,我执行以下操作:当打开iframe所在的模态对话框时,将显示加载指示符。 If the content of the iframe is completely loaded the indicator disappears and the PDF file is shown.
如果iframe的内容已完全加载,则指示符将消失并显示PDF文件。
Here is my code: 这是我的代码:
<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();
});
This solution works well in Safari, FF, Chrome and Opera but not in IE. 此解决方案适用于Safari,FF,Chrome和Opera,但不适用于IE。 How could I achieve that the loading indicator hides and the PDF is shown in IE?
我怎样才能实现加载指示器隐藏并且PDF显示在IE中?
In Google I found some interesting posts about onreadystatechange
and readyState
but this also doesn't working. 在谷歌我发现了一些关于
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/ http://www.nczonline.net/blog/2009/09/15/iframes-onload-and-documentdomain/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.