javascript - How could I check if an iframe have completely loaded a PDF file - Stack Overflow

How could I show a loading indicator while an iframe is loading a PDF file?In my partially working solu

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 pletely 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">&times;</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.

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 pletely 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">&times;</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.

Share Improve this question edited Oct 3, 2014 at 21:53 Patrick Vogt asked Oct 3, 2014 at 21:45 Patrick VogtPatrick Vogt 9163 gold badges16 silver badges35 bronze badges 4
  • 1 possible duplicate of Load event for iFrame not fired in IE – Ben Lesh Commented Oct 3, 2014 at 21:54
  • I have already tried the accepted answer from Load event for iFrame not fired in IE but it seems that the onload event-property is fired when the iframe-tag is pletely loaded. Do you have any other ideas? I am really baffled. – Patrick Vogt Commented Oct 3, 2014 at 21:59
  • 1 have you tried this stackoverflow./a/6455881/1877909 – Hitesh Commented Oct 3, 2014 at 22:01
  • I've just tried your solution but it also doesn't work for me :( – Patrick Vogt Commented Oct 3, 2014 at 22:23
Add a ment  | 

1 Answer 1

Reset to default 3
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/blog/2009/09/15/iframes-onload-and-documentdomain/

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745561192a4633116.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信