h

iframe의 높이를 내용에 맞게 자동으로 맞춰주는 함수

/*    iframe Resizing
    익스플로러 6, 넷스케이프 8 이상에서 작동
    너비는 적용안되고 높이만 자동 리사이즈
    Ex)
        <iframe src="주소" width="640" marginwidth="0" marginheight="0" frameborder="0" onLoad="ResizeIFrame(this);"></iframe>
*/




function resizeIFrame(iframeId)
{
    try {
        var innerBody = iframeId.contentWindow.document.body;
        var innerHeight = innerBody.scrollHeight + (innerBody.offsetHeight - innerBody.clientHeight);
   
        if(iframeId.style.height != innerHeight) {
            iframeId.style.height = innerHeight;
        }
        if(document.all) {
            innerBody.attachEvent('onclick',parent.do_resize);
            innerBody.attachEvent('onkeyup',parent.do_resize);
        }
        else {
            innerBody.addEventListener("click", parent.do_resize, false);
            innerBody.addEventListener("keyup", parent.do_resize, false);
        }
    }
    catch (e) {
    }
}
[이 게시물은 관리자님에 의해 2011-10-31 17:16:08 PHP & HTML에서 이동 됨]
|

댓글 3개

이렇게 하여도 됩니다.

<!-- 아이프레임 창 높이 조절 시작 -->
<script language="JavaScript">
<!--
function calcHeight() {
//find the height of the internal page
var the_height=
document.getElementById('iframe').contentWindow.
document.body.scrollHeight;
//change the height of the iframe
document.getElementById('iframe').height=
the_height;
}
//-->
</script>
<!-- 아이프레임 창 높이 조절 끝 -->

여기까지를 <head>와 </head>사이에 넣으시고


게시판을 삽입하는 곳에는

<!--- 게시판 삽입 시작 -->
<?
echo "<iframe id=iframe onLoad=\"calcHeight();\" src=\"여기에 게시판 주소를 넣으세요\" scrolling=no frameborder=0 width=1000 height=0></iframe>";
?>
<!--- 게시판 삽입 --->
지마켓 등에서 상품 등록시 아이프레임을 사용하려고 하는데, 높이 조절이 자동으로 안되네요..
다른 서버의 웹문서에도 가능한가요???
댓글을 작성하시려면 로그인이 필요합니다. 로그인

프로그램

+
제목 글쓴이 날짜 조회
16년 전 조회 1,998
16년 전 조회 1,967
16년 전 조회 1,500
16년 전 조회 2,027
16년 전 조회 2,263
16년 전 조회 1,381
16년 전 조회 1,720
16년 전 조회 1,910
16년 전 조회 995
16년 전 조회 1,680
16년 전 조회 1,398
16년 전 조회 1,898
16년 전 조회 1,312
16년 전 조회 2,196
16년 전 조회 1,881
16년 전 조회 5,860
16년 전 조회 1,906
16년 전 조회 3,674
16년 전 조회 1,458
16년 전 조회 1,747
16년 전 조회 2,061
16년 전 조회 2,599
16년 전 조회 2,300
16년 전 조회 2,742
16년 전 조회 2,979
16년 전 조회 3,006
16년 전 조회 1,810
16년 전 조회 1,529
16년 전 조회 1,403
16년 전 조회 1,713
16년 전 조회 1,198
16년 전 조회 1,954
16년 전 조회 1,725
16년 전 조회 1,601
16년 전 조회 1,288
16년 전 조회 2,161
16년 전 조회 3,223
16년 전 조회 2,158
16년 전 조회 1,733
16년 전 조회 1,499
16년 전 조회 2,032
16년 전 조회 4,720
16년 전 조회 1,405
16년 전 조회 2,138
16년 전 조회 2,123
16년 전 조회 2,390
16년 전 조회 2,137
17년 전 조회 4,423
17년 전 조회 2,919
17년 전 조회 2,857
17년 전 조회 1,590
17년 전 조회 1,228
17년 전 조회 3,934
17년 전 조회 1,607
17년 전 조회 1,598
17년 전 조회 2,099
17년 전 조회 1,871
17년 전 조회 1,486
17년 전 조회 3,908
17년 전 조회 1,745
17년 전 조회 3,117
17년 전 조회 3,000
17년 전 조회 1,030
17년 전 조회 1,841
17년 전 조회 1,582
17년 전 조회 1,843
17년 전 조회 2,633
17년 전 조회 3,017
17년 전 조회 3,210
17년 전 조회 3,316
17년 전 조회 1,452
17년 전 조회 1,409
17년 전 조회 2,242
17년 전 조회 1,964
17년 전 조회 2,280
17년 전 조회 2,803
17년 전 조회 3,256
17년 전 조회 2,356
17년 전 조회 1,626
17년 전 조회 3,197
17년 전 조회 3,063
17년 전 조회 3,038
17년 전 조회 3,906
17년 전 조회 2,579
17년 전 조회 2,399
17년 전 조회 2,649
17년 전 조회 2,887
17년 전 조회 2,604
17년 전 조회 1,446
17년 전 조회 1,889
17년 전 조회 1,482
17년 전 조회 1,906
17년 전 조회 2,502
17년 전 조회 8,688
17년 전 조회 3,147
17년 전 조회 4,234
17년 전 조회 1,977
17년 전 조회 3,652
17년 전 조회 1,546
17년 전 조회 1,380
🐛 버그신고