2009/03/11 16:02
iframe 사이즈 자동조절 tip/javascript2009/03/11 16:02
1.아래 코드를 아이프레임이 들어갈 메인페이지에 삽입세요.
2. 아래와 같이 iframe을 호출하는 부분에서 onload 이벤트에서 호출하면 끝!.
function resizeFrame(iframeObj){
var innerBody = iframeObj.contentWindow.document.body;
var innerHeight = innerBody.scrollHeight + (innerBody.offsetHeight - innerBody.clientHeight);
var innerWidth = innerBody.scrollWidth + (innerBody.offsetWidth - innerBody.clientWidth);
if(innerHeight>0 && innerWidth>0){
iframeObj.style.height = innerHeight;
iframeObj.style.width = innerWidth;
}
}
var innerBody = iframeObj.contentWindow.document.body;
var innerHeight = innerBody.scrollHeight + (innerBody.offsetHeight - innerBody.clientHeight);
var innerWidth = innerBody.scrollWidth + (innerBody.offsetWidth - innerBody.clientWidth);
if(innerHeight>0 && innerWidth>0){
iframeObj.style.height = innerHeight;
iframeObj.style.width = innerWidth;
}
}
2. 아래와 같이 iframe을 호출하는 부분에서 onload 이벤트에서 호출하면 끝!.
<iframe src="" name="iPub_list" onload="resizeFrame(this)" style="width:100%" frameborder="0" scrolling="no"></iframe>
'tip > javascript' 카테고리의 다른 글
| div태그로 지정된 영역만 출력 (0) | 2009/05/06 |
|---|---|
| iframe 사이즈 자동조절 (0) | 2009/03/11 |
| HTML 간단한 새창 띄우기 (0) | 2009/03/03 |
