ifrmae 자동 리사이즈

· 17년 전 · 3258 · 4
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js">
</script>

<iframe class="resize" src="/" frameborder="0" scrolling="no"></iframe>

<script type="text/javascript">
$(function(){
  $("iframe.resize").load(function(){
    var frame = $(this).get(0);
    var doc = (frame.contentDocument) ? frame.contentDocument : frame.contentWindow.document;
    $(this).height(doc.body.scrollHeight);
    //$(this).width(doc.body.scrollWidth); // 너비도 자동적용하려면 주석 제거
  });
});
</script>
[이 게시물은 관리자님에 의해 2011-10-31 16:55:28 jQuery에서 이동 됨]
|

댓글 4개

한때 이 것 때문에 무진장 고생했었는데
잘 되나요?
브라우저 호환은 문제없나요? ^^;

함 해봐야겠네요 ㅎㅎ 암튼 감사합니다.
// 약간 문제가 있어서 수정 했습니다.
// height 속성이 없는 iframe에 대해서만 높이 자동 지정
// jquery.livequery.js 사용

$.iresize = function() {
try {
$("iframe[height=]")
.livequery("load", function() {
var doc = $(this).contents().find($.browser.msie ? 'body#' : 'body');
$(this).height(doc.height());
});
} catch (e) {}
}

$.iresize();
이렇게 하면 페이지 네이 있는 iframe 전체가 다 수정되는거 아닌가요?
name 과 options 를 지정 하심이..^^

가로와 세로를 선택적으로 사용가능하게말이죠..^^

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$.iresize = function(name, options) {
var settings = {width:true, height:true}
$.extend(settings, options);
try {
$(name)
.livequery("load", function() {
var doc = $(this).contents().find($.browser.msie ? 'body#' : 'body');
if(settings.width) $(this).width(doc.width());
if(settings.height) $(this).height(doc.height());
});
} catch (e) {}
}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$.iresize("element",{width:false}); // height 만 맞춤
$.iresize("element",{height:false}); // width 만 맞춤
$.iresize("element"); // 둘다 맞춤
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
이런식이 된다면 이렇게 하는것이 좋을듯 해 보입니다..^^
ifrmae - > iframe 이 맞죠 .?
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
16년 전 조회 1,801
16년 전 조회 2,110
16년 전 조회 2,646
16년 전 조회 2,357
16년 전 조회 2,788
16년 전 조회 3,035
16년 전 조회 3,053
16년 전 조회 1,866
16년 전 조회 1,585
16년 전 조회 1,457
16년 전 조회 1,770
16년 전 조회 1,245
16년 전 조회 2,012
16년 전 조회 1,774
16년 전 조회 1,651
17년 전 조회 1,331
17년 전 조회 2,208
17년 전 조회 3,274
17년 전 조회 2,206
17년 전 조회 1,785
17년 전 조회 1,554
17년 전 조회 2,086
17년 전 조회 4,776
17년 전 조회 1,461
17년 전 조회 2,192
17년 전 조회 2,168
17년 전 조회 2,440
17년 전 조회 2,190
17년 전 조회 4,473
17년 전 조회 2,971
17년 전 조회 2,914
17년 전 조회 1,638
17년 전 조회 1,287
17년 전 조회 3,992
17년 전 조회 1,658
17년 전 조회 1,656
17년 전 조회 2,154
17년 전 조회 1,928
17년 전 조회 1,539
17년 전 조회 3,959
17년 전 조회 1,792
17년 전 조회 3,172
17년 전 조회 3,041
17년 전 조회 1,080
17년 전 조회 1,888
17년 전 조회 1,638
17년 전 조회 1,888
17년 전 조회 2,678
17년 전 조회 3,067
17년 전 조회 3,259
17년 전 조회 3,365
17년 전 조회 1,505
17년 전 조회 1,457
17년 전 조회 2,293
17년 전 조회 2,021
17년 전 조회 2,326
17년 전 조회 2,855
17년 전 조회 3,302
17년 전 조회 2,405
17년 전 조회 1,676
17년 전 조회 3,251
17년 전 조회 3,113
17년 전 조회 3,088
17년 전 조회 3,956
17년 전 조회 2,634
17년 전 조회 2,450
17년 전 조회 2,692
17년 전 조회 2,931
17년 전 조회 2,653
17년 전 조회 1,493
17년 전 조회 1,935
17년 전 조회 1,526
17년 전 조회 1,954
17년 전 조회 2,554
17년 전 조회 8,737
17년 전 조회 3,196
17년 전 조회 4,287
17년 전 조회 2,025
17년 전 조회 3,704
17년 전 조회 1,601
17년 전 조회 1,424
17년 전 조회 2,365
17년 전 조회 1,352
17년 전 조회 1,676
17년 전 조회 1,511
17년 전 조회 2,569
17년 전 조회 1,539
17년 전 조회 1,133
17년 전 조회 1,265
17년 전 조회 3,149
17년 전 조회 2,194
17년 전 조회 2,007
17년 전 조회 1,259
17년 전 조회 2,485
17년 전 조회 1,206
17년 전 조회 1,174
17년 전 조회 1,419
17년 전 조회 2,783
17년 전 조회 2,429
17년 전 조회 2,516