admin管理员组

文章数量:1026989

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/

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/

本文标签: javascriptHow could I check if an iframe have completely loaded a PDF fileStack Overflow