2010-11-30 4 views
9

나는 JS 파일 업 로더에서이 "iframe.contentDocument"를 사용하지만 IE8, 파이어 폭스 (3.5 및 버전 이하가 작동하지 않습니다. 을 내가 iframe이 작업을위한 다른 DOM의를 사용하여이 문제를 해결 할 수 있습니까?"iframe.contentDocument"IE8 및 FF (3.5 이하)에서이 문제를 해결하기위한 다른 단계가 작동하지 않습니까?

감사합니다 모든

+0

을보십시오. 당신은 jQuery를 접근 방법을 시도 할 수 있습니다. http://www.dynamicdrive.com 체크 아웃 /forums/showthread.php?t=29359 – matthewpavkov

답변

11

에 내가 IE, FF, 등, iframe.contentDocument을 처리하는 방법의 차이가 생각

var doc; 
var iframeObject = document.getElementById('iframeID'); // MUST have an ID 
if (iframeObject.contentDocument) { // DOM 
    doc = iframeObject.contentDocument; 
} 
else if (iframeObject.contentWindow) { // IE win 
    doc = iframeObject.contentWindow.document; 
} 
if (doc) { 
    var something = doc.getElementById('someId'); 
} 
else { 
    alert('Wonder what browser this is...'+navigator.userAgent); 
} 
+0

감사합니다 mplungjan. – ajay