html소스 아이프레임 높이 자동조절

2010.10.17 15:48

juro 조회 수:1623

아이프레임 부모 페이지에 삽입할 코드 입니다.
<iframe name="iframe1" id="iframe1" src="링크주소" width="기본 가로사이즈" height="기본 세로 사이즈" frameboarder="0" scrolling="no"
marginwidth=0 marginheight=0></iframe>


아이프레임에 링크될 페이지 하단에 삽입할 코드입니다.
<script type="text/javascript" language="javascript">
var obody=document.body;
obody.style.position='absolute';
obody.style.top='0';
obody.style.left='0';
var h, w;
if(navigator.userAgent.indexOf("MSIE")== -1) {
h=obody.scrollHeight;
w=obody.scrollWidth;
} else {
h=obody.scrollHeight+obody.offsetHeight-obody.clientHeight;
w=obody.scrollWidth+obody.offsetWidth-obody.clientWidth;
}

parent.document.getElementById('iframe1').height=h;
</script>
[출처] 아이프레임 자동 높이 조절|작성자 on_mkt

© juroweb 2003-2014. All rights reserved
log in