iframe 높이 질문입니다. 채택완료
현재 스크립트를 이용하여 높이를 자동 조절하고 있습니다.
<iframe id="iframe_show" style="position: relative;" name="iframe_show" marginheight="0" marginwidth="0" frameborder="0" onload="changeHeight()"
width="100%" height="1000" scrolling="no">
</iframe>
<script>
function changeHeight() {
var the_height=document.getElementById('iframe_show').contentWindow.document.body.scrollHeight;
document.getElementById('iframe_show').height=the_height; }
</script>
이렇게 설정을 한뒤 iframe을 이용하여 view페이지를 보면 일단은 자동으로 스크롤이 생기게 됩니다.
그런데 문제가 내용이 긴 게시글를 들어가면 스크롤이 길게 나타난 후 다른 짧은 게시글로 들어가게 되면 그 스크롤이 계속 유지가 되더라구요.. 짧은 만큼 스크롤이 없어지거나 짧아져야하는데...
어떤 문제인지 궁금합니다. 조언 부탁드리겠습니다.
(추가) 파이어폭스에서는 잘 되지만 크롬에서 안됩니다.
답변 2개
아래 소스로도 시도해 보세요.
크롬에서 잘되는 합니다 ㅎ
</p><p><script></p><p>$(function(){</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>// iframe height auto resize</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>var height = window.innerHeight; </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$('iframe').css('height', height); </p><p> </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$(window).resize(function(){ </p><p> <span class="Apple-tab-span" style="white-space:pre"> </span>var height = window.innerHeight; </p><p> <span class="Apple-tab-span" style="white-space:pre"> </span>$('iframe').css('height', height); </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>});</p><p>});</p><p></script></p><p>
답변에 대한 댓글 3개
<a href="http://www.daum.net" target="i_f">다음</a><br>
<a href="http://navycolor.com" target="i_f">네이비컬러</a><br><br>
<iframe width="100%" height="500px" name="i_f" frameborder=1></iframe>
댓글을 작성하려면 로그인이 필요합니다.
게시판 스킨에 ID값을 주고
게시판 height 값을 구한다음에
그값을 Iframe height 값으로 주는 방식이 맞지 않을까요?
newheight = $("#"+id).contents().find("#mainContent").height(); // mainContent 가 게시판스킨 아이디
document.getElementById(id).height= (newheight) + "px"; // id 는 iframe 아이디
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인