아이프레임 쓸때 height때문에 제대로 된 페이지를 구성하지 못할때가 있다.
아래 함수를 쓰면 유용하게 아이프렘임을 이용할수 있겠다.
<script>
function Resize_Frame(name)
{
try
{
var oBody = document.frames(name).document.body;
var oFrame = document.all(name);
oFrame.style.width
= oBody.scrollWidth + (oBody.offsetWidth- oBody.clientWidth);
oFrame.style.height
= oBody.scrollHeight + (oBody.offsetHeight-oBody.clientHeight);
//요건 아이프레임 페이지가 제대로 안됬을때..
if (oFrame.style.height == "0px" || oFrame.style.width == "0px")
{
oFrame.style.width = "800";
oFrame.style.height = "300px";
window.status = 'iframe resizing fail.';
}
else
{
window.status = '';
}
}
catch(e)
{
window.status = 'Error: ' + e.number + '; ' + e.description;
}
}
</script>
함수 호출할때는..
<IFRAME onLoad="Resize_Frame('test')" name="test" width=200 NORESIZE SCROLLING=No FRAMEBORDER=0 MARGINHEIGHT=0 MARGINWIDTH=0
SRC="source_iframe.html">
</IFRAME>
예제 페이지는..
http://bluesoul.hani.co.kr/test/resize_iframe.html
날짜: 2004-04-19 19:42:19,
조회수: 2773 |