iframe height 자동조절
페이지 정보

본문
일단 아래 script를 추가해준다.
<script type="text/javascript">
//<![CDATA[
function calcHeight(){
//find the height of the internal page
var the_height=
document.getElementById('the_iframe').contentWindow.
document.body.scrollHeight;
//change the height of the iframe
document.getElementById('the_iframe').height=
the_height;
//document.getElementById('the_iframe').scrolling = "no";
document.getElementById('the_iframe').style.overflow = "hidden";
}
//
</script>
그리고 위 스크립트를 실행할 수 있도록 아이프레임에 onload와 id로 불러온다.
최소 높이(min-height)도 설정
<iframe src="아이프레임.html" id="the_iframe" onload="calcHeight();" name="" title="" frameborder="0" scrolling="no" style="overflow-x:hidden; overflow:auto; width:100%; min-height:500px;"></iframe>
이렇게하면 사용하는 브라우저에 맞도록, 나의 컨텐츠에 맞도록
iframe의 height가 자동으로 100%로 설정된다.
- 이전글유튜브 소리 크기 증폭하는 방법 21.09.11
- 다음글[htaccess] 특정 url 차단하기 21.08.19
댓글목록
등록된 댓글이 없습니다.