ifrmae 자동 리사이즈

· 17년 전 · 3214 · 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,751
16년 전 조회 2,066
16년 전 조회 2,603
16년 전 조회 2,305
16년 전 조회 2,746
16년 전 조회 2,983
16년 전 조회 3,011
16년 전 조회 1,817
16년 전 조회 1,536
16년 전 조회 1,409
16년 전 조회 1,720
16년 전 조회 1,203
16년 전 조회 1,959
16년 전 조회 1,730
16년 전 조회 1,607
16년 전 조회 1,295
16년 전 조회 2,167
16년 전 조회 3,227
16년 전 조회 2,163
16년 전 조회 1,736
16년 전 조회 1,504
16년 전 조회 2,038
16년 전 조회 4,724
16년 전 조회 1,412
17년 전 조회 2,147
17년 전 조회 2,131
17년 전 조회 2,398
17년 전 조회 2,144
17년 전 조회 4,428
17년 전 조회 2,927
17년 전 조회 2,862
17년 전 조회 1,595
17년 전 조회 1,234
17년 전 조회 3,940
17년 전 조회 1,613
17년 전 조회 1,605
17년 전 조회 2,106
17년 전 조회 1,878
17년 전 조회 1,492
17년 전 조회 3,914
17년 전 조회 1,752
17년 전 조회 3,126
17년 전 조회 3,005
17년 전 조회 1,035
17년 전 조회 1,846
17년 전 조회 1,586
17년 전 조회 1,850
17년 전 조회 2,636
17년 전 조회 3,021
17년 전 조회 3,215
17년 전 조회 3,321
17년 전 조회 1,458
17년 전 조회 1,416
17년 전 조회 2,248
17년 전 조회 1,971
17년 전 조회 2,287
17년 전 조회 2,812
17년 전 조회 3,261
17년 전 조회 2,361
17년 전 조회 1,629
17년 전 조회 3,202
17년 전 조회 3,069
17년 전 조회 3,043
17년 전 조회 3,913
17년 전 조회 2,584
17년 전 조회 2,404
17년 전 조회 2,653
17년 전 조회 2,894
17년 전 조회 2,608
17년 전 조회 1,449
17년 전 조회 1,894
17년 전 조회 1,486
17년 전 조회 1,909
17년 전 조회 2,508
17년 전 조회 8,693
17년 전 조회 3,151
17년 전 조회 4,241
17년 전 조회 1,981
17년 전 조회 3,656
17년 전 조회 1,551
17년 전 조회 1,384
17년 전 조회 2,320
17년 전 조회 1,313
17년 전 조회 1,627
17년 전 조회 1,460
17년 전 조회 2,530
17년 전 조회 1,495
17년 전 조회 1,088
17년 전 조회 1,221
17년 전 조회 3,098
17년 전 조회 2,162
17년 전 조회 1,967
17년 전 조회 1,212
17년 전 조회 2,447
17년 전 조회 1,167
17년 전 조회 1,127
17년 전 조회 1,373
17년 전 조회 2,737
17년 전 조회 2,392
17년 전 조회 2,477
🐛 버그신고