통합검색

Javascript

[jQuery] iframe 높이를 문서 높이에 따라 자동 조절



iframe 내부 문서의 높이에 따라 iframe의 height를 자동으로 조절해주는 코드.


[!]HTML[/!]
<iframe src="document.html" frameborder="0" scrolling="no></iframe>


[!]jQuery[/!]
<script type="text/javascript">
$('iframe').load(function(){
    $(this).height(0);
    setTimeout(
        function() {
            $(this).height($(this).contents().find('body').height() + 150),
        },
        100
    );
});
</script>