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,032
16년 전 조회 1,996
16년 전 조회 1,531
16년 전 조회 2,056
16년 전 조회 2,291
16년 전 조회 1,408
16년 전 조회 1,757
16년 전 조회 1,938
16년 전 조회 1,032
16년 전 조회 1,714
16년 전 조회 1,427
16년 전 조회 1,924
16년 전 조회 1,339
16년 전 조회 2,223
16년 전 조회 1,912
16년 전 조회 5,885
16년 전 조회 1,934
16년 전 조회 3,705
16년 전 조회 1,487
16년 전 조회 1,776
16년 전 조회 2,086
16년 전 조회 2,628
16년 전 조회 2,328
16년 전 조회 2,769
16년 전 조회 3,011
16년 전 조회 3,034
16년 전 조회 1,841
16년 전 조회 1,562
16년 전 조회 1,434
16년 전 조회 1,748
16년 전 조회 1,222
16년 전 조회 1,986
16년 전 조회 1,754
16년 전 조회 1,628
17년 전 조회 1,312
17년 전 조회 2,191
17년 전 조회 3,254
17년 전 조회 2,181
17년 전 조회 1,759
17년 전 조회 1,532
17년 전 조회 2,062
17년 전 조회 4,752
17년 전 조회 1,435
17년 전 조회 2,166
17년 전 조회 2,151
17년 전 조회 2,423
17년 전 조회 2,170
17년 전 조회 4,456
17년 전 조회 2,949
17년 전 조회 2,889
17년 전 조회 1,617
17년 전 조회 1,262
17년 전 조회 3,966
17년 전 조회 1,636
17년 전 조회 1,633
17년 전 조회 2,133
17년 전 조회 1,904
17년 전 조회 1,521
17년 전 조회 3,938
17년 전 조회 1,773
17년 전 조회 3,156
17년 전 조회 3,023
17년 전 조회 1,057
17년 전 조회 1,870
17년 전 조회 1,614
17년 전 조회 1,864
17년 전 조회 2,658
17년 전 조회 3,041
17년 전 조회 3,238
17년 전 조회 3,347
17년 전 조회 1,481
17년 전 조회 1,437
17년 전 조회 2,276
17년 전 조회 2,002
17년 전 조회 2,310
17년 전 조회 2,835
17년 전 조회 3,283
17년 전 조회 2,378
17년 전 조회 1,652
17년 전 조회 3,226
17년 전 조회 3,087
17년 전 조회 3,066
17년 전 조회 3,935
17년 전 조회 2,608
17년 전 조회 2,430
17년 전 조회 2,678
17년 전 조회 2,916
17년 전 조회 2,634
17년 전 조회 1,473
17년 전 조회 1,917
17년 전 조회 1,509
17년 전 조회 1,934
17년 전 조회 2,527
17년 전 조회 8,715
17년 전 조회 3,172
17년 전 조회 4,267
17년 전 조회 2,003
17년 전 조회 3,676
17년 전 조회 1,576
17년 전 조회 1,406