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년 전 조회 2,073
16년 전 조회 2,047
16년 전 조회 1,583
16년 전 조회 2,111
16년 전 조회 2,348
16년 전 조회 1,458
16년 전 조회 1,803
16년 전 조회 1,991
16년 전 조회 1,079
16년 전 조회 1,760
16년 전 조회 1,470
16년 전 조회 1,972
16년 전 조회 1,385
16년 전 조회 2,276
16년 전 조회 1,961
16년 전 조회 5,934
16년 전 조회 1,983
16년 전 조회 3,751
16년 전 조회 1,539
16년 전 조회 1,821
16년 전 조회 2,137
16년 전 조회 2,679
16년 전 조회 2,380
16년 전 조회 2,816
16년 전 조회 3,053
16년 전 조회 3,079
16년 전 조회 1,886
16년 전 조회 1,602
16년 전 조회 1,473
16년 전 조회 1,790
16년 전 조회 1,271
16년 전 조회 2,034
16년 전 조회 1,807
17년 전 조회 1,674
17년 전 조회 1,362
17년 전 조회 2,233
17년 전 조회 3,297
17년 전 조회 2,220
17년 전 조회 1,808
17년 전 조회 1,574
17년 전 조회 2,103
17년 전 조회 4,794
17년 전 조회 1,484
17년 전 조회 2,212
17년 전 조회 2,185
17년 전 조회 2,464
17년 전 조회 2,210
17년 전 조회 4,497
17년 전 조회 3,000
17년 전 조회 2,938
17년 전 조회 1,658
17년 전 조회 1,304
17년 전 조회 4,021
17년 전 조회 1,682
17년 전 조회 1,681
17년 전 조회 2,180
17년 전 조회 1,953
17년 전 조회 1,572
17년 전 조회 3,983
17년 전 조회 1,819
17년 전 조회 3,200
17년 전 조회 3,070
17년 전 조회 1,104
17년 전 조회 1,911
17년 전 조회 1,673
17년 전 조회 1,919
17년 전 조회 2,701
17년 전 조회 3,101
17년 전 조회 3,279
17년 전 조회 3,391
17년 전 조회 1,532
17년 전 조회 1,489
17년 전 조회 2,315
17년 전 조회 2,042
17년 전 조회 2,360
17년 전 조회 2,882
17년 전 조회 3,331
17년 전 조회 2,427
17년 전 조회 1,694
17년 전 조회 3,278
17년 전 조회 3,132
17년 전 조회 3,112
17년 전 조회 3,981
17년 전 조회 2,653
17년 전 조회 2,469
17년 전 조회 2,718
17년 전 조회 2,964
17년 전 조회 2,677
17년 전 조회 1,507
17년 전 조회 1,954
17년 전 조회 1,543
17년 전 조회 1,977
17년 전 조회 2,577
17년 전 조회 8,755
17년 전 조회 3,220
17년 전 조회 4,313
17년 전 조회 2,054
17년 전 조회 3,730
17년 전 조회 1,625
17년 전 조회 1,448