Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/388.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何检查iframe是否已完全加载PDF文件_Javascript_Jquery_Internet Explorer_Iframe_Cross Browser - Fatal编程技术网

Javascript 如何检查iframe是否已完全加载PDF文件

Javascript 如何检查iframe是否已完全加载PDF文件,javascript,jquery,internet-explorer,iframe,cross-browser,Javascript,Jquery,Internet Explorer,Iframe,Cross Browser,iframe加载PDF文件时,如何显示加载指示器 在部分工作的解决方案中,我执行以下操作:当打开模式对话框(其中包含iframe)时,会出现一个加载指示器。如果iframe的内容已完全加载,则指示器将消失,并显示PDF文件 这是我的密码: <div data-gid="<?php echo $gid; ?>" class="modal fade" id="sammelPDF" tabindex="-1" role="dialog" aria-labelledby="sammel

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">&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();
});


可能重复的我已经尝试了接受的答案,但是当iframe标记完全加载时,
onload
事件属性似乎被触发。你还有别的想法吗?我真的很困惑。你试过了吗?我刚试过你的解决方案,但它对我也不起作用:(我刚试过你的解决方案,但它不起作用:(当我用
iframe.addEventListener
添加
时,如果使用
iframe.addEventListener
,则选择了此分支,但似乎没有执行事件的回调方法。
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.");
    };
}