ifrmae 자동 리사이즈

· 17년 전 · 3489 · 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년 전 조회 2,012
16년 전 조회 2,365
16년 전 조회 2,888
16년 전 조회 2,595
17년 전 조회 3,027
17년 전 조회 3,261
17년 전 조회 3,279
17년 전 조회 2,083
17년 전 조회 1,808
17년 전 조회 1,675
17년 전 조회 2,002
17년 전 조회 1,489
17년 전 조회 2,235
17년 전 조회 2,003
17년 전 조회 1,864
17년 전 조회 1,565
17년 전 조회 2,441
17년 전 조회 3,508
17년 전 조회 2,410
17년 전 조회 2,007
17년 전 조회 1,792
17년 전 조회 2,312
17년 전 조회 4,996
17년 전 조회 1,712
17년 전 조회 2,449
17년 전 조회 2,414
17년 전 조회 2,682
17년 전 조회 2,405
17년 전 조회 4,725
17년 전 조회 3,219
17년 전 조회 3,133
17년 전 조회 1,849
17년 전 조회 1,507
17년 전 조회 4,237
17년 전 조회 1,910
17년 전 조회 1,908
17년 전 조회 2,393
17년 전 조회 2,157
17년 전 조회 1,794
17년 전 조회 4,203
17년 전 조회 2,035
17년 전 조회 3,376
17년 전 조회 3,301
17년 전 조회 1,294
17년 전 조회 2,111
17년 전 조회 1,863
17년 전 조회 2,119
17년 전 조회 2,928
17년 전 조회 3,288
17년 전 조회 3,490
17년 전 조회 3,605
17년 전 조회 1,702
17년 전 조회 1,696
17년 전 조회 2,506
17년 전 조회 2,250
17년 전 조회 2,541
17년 전 조회 3,081
17년 전 조회 3,564
17년 전 조회 2,637
17년 전 조회 1,912
17년 전 조회 3,497
17년 전 조회 3,338
17년 전 조회 3,309
17년 전 조회 4,190
17년 전 조회 2,828
17년 전 조회 2,691
17년 전 조회 2,940
17년 전 조회 3,177
17년 전 조회 2,890
17년 전 조회 1,731
17년 전 조회 2,138
17년 전 조회 1,734
17년 전 조회 2,192
17년 전 조회 2,817
17년 전 조회 8,977
17년 전 조회 3,418
17년 전 조회 4,486
17년 전 조회 2,248
17년 전 조회 3,921
17년 전 조회 1,817
17년 전 조회 1,640
17년 전 조회 2,572
17년 전 조회 1,569
17년 전 조회 1,874
17년 전 조회 1,729
17년 전 조회 2,796
17년 전 조회 1,749
17년 전 조회 1,342
17년 전 조회 1,493
17년 전 조회 3,387
17년 전 조회 2,421
17년 전 조회 2,213
17년 전 조회 1,471
17년 전 조회 2,694
17년 전 조회 1,428
17년 전 조회 1,389
17년 전 조회 1,644
17년 전 조회 3,004
17년 전 조회 2,660
17년 전 조회 2,717