2013-08-04 6 views
0

내용에 따라 iframe의 높이를 동적으로 변경하려고합니다.Chrome에서 iframe 문서 가져 오기

그러나 크롬의 최신 버전에서는 작동하지 않습니다.

doc는 크롬에 'undefined'입니다.

Firefox에서 잘 작동합니다.

내가 뭘 잘못하고 있니?

<script> 
    $(function() { 

     $('#iframeid') 
       .load(
         function() { 

          try { 
           var doc = this.contentDocument ? this.contentDocument 
             : this.contentWindow.document; 
           alert(doc); 
          } catch (e) { 
           alert(e.message); 
          } 
         }); 

    }); 
</script> 
<iframe frameborder="0" id="iframeid" src="iframesource2.html" 
    height="1px"> </iframe> 

답변

0

나를 위해 일하는 것 같습니다. this fiddle을보십시오.

$(function() { 
    $('#iframeid').load(function() { 
     try { 
      var doc = this.contentDocument || this.contentWindow.document; 
      alert(doc); 
     } catch (e) { 
      alert(e.message); 
     } 
    }); 
}); 
: 정말 아무것도 변경하지 마십시오

일부 작은 변화