출처 :
http://naradesign.net/wp/2007/12/12/129/
http://blog.naver.com/PostView.nhn?blogId=kyo1230&logNo=140168019949
방법1
iframe 의 사용이 권장되는 것은 아니지만 간혹 사용되는 경우 컨텐트의 높이에 따라 자동으로 resizing 되도록 하는 방법은 사용성을 높여줍니다. iframe 내부의 콘텐트 높이가 동적으로 달라지는 경우 고정된 높이로는 이것을 담아낼 수 없기에 스크롤이 나타나도록 처리하는 방법 대신 프레임 콘텐트의 내용이 스크롤 없이 모두 출력될 수 있도록 해 주는것이 좋겠지요.
문서의 <head> 영역에 포함되어야 할 스크립트.
<script type="text/javascript">
// iframe resize
function autoResize(i)
{
var iframeHeight=
(i).contentWindow.document.body.scrollHeight;
(i).height=iframeHeight+20;
}
</script>
문서의 <iframe> 코드에 포함되어야 할 스크립트.
<iframe src="#iframeUrl" onload="autoResize(this)" scrolling="no" frameborder="0"></iframe>
기타
- 같은 도메인 URL을 지닌 iframe 콘텐트에만 이 스크립트를 사용할 수 있습니다.
- IE6~7, FF2, Opera9, Safari2~3 크로스 브라우징을 확인 하였습니다.
참조
var oldonload = window.onload;
if(typeof window.onload != “function”){
window.onload = func;
}else{
window.onload = function(){
oldonload();
func();
}
}
}
function resize(){
var height = document.body.scrollHeight;
parent.document.getElementById(“iframeID”).style.height = height + 50 + “px”;
}
addLoadEvent(resize);
<script language="JavaScript">
function calcHeight()
{
//find the height of the internal page
var the_height=
document.getElementById('the_iframe').contentWindow.
document.body.scrollHeight;
//change the height of the iframe
document.getElementById('the_iframe').height=
the_height;
}
</script>
<iframe width="700" id="the_iframe" onLoad="calcHeight();" src="cms_m1.html" scrolling="NO" frameborder="0" height="1"></iframe>
방법4.
iframe auto resize (cross browsing)
아이프레임 자동 리사이즈 (크로스 브라우징)
test browser : ie6, ie7, firefox 3, safari 3, chrome, opera 9
[출처] iframe resize|작성자 산타랠리