Reputation: 916
How could I show a loading indicator while an iframe is loading a PDF file?
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. If the content of the iframe is completely loaded the indicator disappears and the PDF file is shown.
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. How could I achieve that the loading indicator hides and the PDF is shown in IE?
In Google I found some interesting posts about onreadystatechange
and readyState
but this also doesn't working.
Upvotes: 4
Views: 8085
Reputation: 4288
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/
Upvotes: 3