ifrmae 자동 리사이즈

· 17년 전 · 3245 · 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,793
16년 전 조회 2,102
16년 전 조회 2,637
16년 전 조회 2,347
16년 전 조회 2,783
16년 전 조회 3,021
16년 전 조회 3,043
16년 전 조회 1,854
16년 전 조회 1,571
16년 전 조회 1,444
16년 전 조회 1,759
16년 전 조회 1,235
16년 전 조회 1,997
16년 전 조회 1,763
16년 전 조회 1,639
17년 전 조회 1,322
17년 전 조회 2,196
17년 전 조회 3,265
17년 전 조회 2,191
17년 전 조회 1,775
17년 전 조회 1,545
17년 전 조회 2,077
17년 전 조회 4,765
17년 전 조회 1,449
17년 전 조회 2,181
17년 전 조회 2,159
17년 전 조회 2,429
17년 전 조회 2,175
17년 전 조회 4,462
17년 전 조회 2,959
17년 전 조회 2,899
17년 전 조회 1,628
17년 전 조회 1,276
17년 전 조회 3,976
17년 전 조회 1,646
17년 전 조회 1,644
17년 전 조회 2,146
17년 전 조회 1,912
17년 전 조회 1,530
17년 전 조회 3,949
17년 전 조회 1,778
17년 전 조회 3,167
17년 전 조회 3,030
17년 전 조회 1,065
17년 전 조회 1,881
17년 전 조회 1,625
17년 전 조회 1,875
17년 전 조회 2,670
17년 전 조회 3,061
17년 전 조회 3,246
17년 전 조회 3,357
17년 전 조회 1,493
17년 전 조회 1,444
17년 전 조회 2,287
17년 전 조회 2,009
17년 전 조회 2,321
17년 전 조회 2,845
17년 전 조회 3,292
17년 전 조회 2,392
17년 전 조회 1,662
17년 전 조회 3,232
17년 전 조회 3,093
17년 전 조회 3,075
17년 전 조회 3,947
17년 전 조회 2,620
17년 전 조회 2,437
17년 전 조회 2,685
17년 전 조회 2,923
17년 전 조회 2,645
17년 전 조회 1,484
17년 전 조회 1,926
17년 전 조회 1,514
17년 전 조회 1,943
17년 전 조회 2,542
17년 전 조회 8,721
17년 전 조회 3,183
17년 전 조회 4,275
17년 전 조회 2,013
17년 전 조회 3,691
17년 전 조회 1,589
17년 전 조회 1,412
17년 전 조회 2,352
17년 전 조회 1,344
17년 전 조회 1,662
17년 전 조회 1,496
17년 전 조회 2,562
17년 전 조회 1,529
17년 전 조회 1,126
17년 전 조회 1,257
17년 전 조회 3,133
17년 전 조회 2,184
17년 전 조회 1,997
17년 전 조회 1,242
17년 전 조회 2,476
17년 전 조회 1,198
17년 전 조회 1,163
17년 전 조회 1,406
17년 전 조회 2,773
17년 전 조회 2,419
17년 전 조회 2,506