2014-10-03 2 views
4

iframe에서 PDF 파일을로드하는 동안로드 표시기를 표시하려면 어떻게해야합니까?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(); 
}); 

이 솔루션은 IE에서 사파리, FF, 크롬과 오페라에서 잘 작동하지만 :

여기 내 코드입니다. 로딩 표시기가 숨겨지고 PDF가 IE에 표시되는 것을 어떻게 얻을 수 있습니까?

Google에서 onreadystatechangereadyState에 대한 흥미로운 소식을 발견했지만 이것도 작동하지 않습니다.

+1

의 중복 가능성 http://stackoverflow.com/questions/4334520/load-event-for-iframe-not-fired-in -ie) –

+0

나는 [IE에서 해고되지 iFrame에 대한로드 이벤트]에서 허용 대답을 이미 시도했다 (http://stackoverflow.com/questions/4334520/load-event-for-iframe-not-fired-in-ie)하지만 iframe 태그가 완전히로드되면 onload 이벤트 속성이 시작되는 것으로 보입니다. 다른 아이디어가 있습니까? 나는 정말로 당혹 스럽다. –

+1

당신은 이것을 시도한 적이 있습니까? http://stackoverflow.com/a/6455881/1877909 – Hitesh

답변

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.net/blog/2009/09/15/iframes-onload-and-documentdomain/

[IE의 앞쪽은 iframe로드 이벤트 (
+0

방금 ​​솔루션을 시도했지만 해결하지 못했습니다. work :('else if'에'iframe.addEventListener'를 추가하면이 분기가 선택되지만 이벤트에 대한 콜백 메소드가 실행되지 않은 것 같습니다. –

+0

@PatrickVogt : 작업 복사본이나 jsfidddle이 있습니까? .. – Hitesh

+0

@PatrickVogt : IE의 어떤 버전이 작동하지 않습니다 – Hitesh

관련 문제