ifrmae 자동 리사이즈

· 17년 전 · 3504 · 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,032
16년 전 조회 2,390
17년 전 조회 2,911
17년 전 조회 2,616
17년 전 조회 3,048
17년 전 조회 3,282
17년 전 조회 3,308
17년 전 조회 2,107
17년 전 조회 1,832
17년 전 조회 1,698
17년 전 조회 2,023
17년 전 조회 1,503
17년 전 조회 2,264
17년 전 조회 2,037
17년 전 조회 1,892
17년 전 조회 1,590
17년 전 조회 2,457
17년 전 조회 3,526
17년 전 조회 2,428
17년 전 조회 2,028
17년 전 조회 1,814
17년 전 조회 2,330
17년 전 조회 5,015
17년 전 조회 1,725
17년 전 조회 2,467
17년 전 조회 2,428
17년 전 조회 2,706
17년 전 조회 2,429
17년 전 조회 4,742
17년 전 조회 3,242
17년 전 조회 3,152
17년 전 조회 1,869
17년 전 조회 1,528
17년 전 조회 4,256
17년 전 조회 1,927
17년 전 조회 1,923
17년 전 조회 2,412
17년 전 조회 2,174
17년 전 조회 1,809
17년 전 조회 4,221
17년 전 조회 2,053
17년 전 조회 3,387
17년 전 조회 3,316
17년 전 조회 1,313
17년 전 조회 2,125
17년 전 조회 1,883
17년 전 조회 2,140
17년 전 조회 2,941
17년 전 조회 3,304
17년 전 조회 3,505
17년 전 조회 3,621
17년 전 조회 1,716
17년 전 조회 1,710
17년 전 조회 2,519
17년 전 조회 2,265
17년 전 조회 2,556
17년 전 조회 3,111
17년 전 조회 3,579
17년 전 조회 2,655
17년 전 조회 1,923
17년 전 조회 3,507
17년 전 조회 3,355
17년 전 조회 3,325
17년 전 조회 4,209
17년 전 조회 2,844
17년 전 조회 2,705
17년 전 조회 2,959
17년 전 조회 3,193
17년 전 조회 2,908
17년 전 조회 1,756
17년 전 조회 2,150
17년 전 조회 1,748
17년 전 조회 2,207
17년 전 조회 2,831
17년 전 조회 8,991
17년 전 조회 3,432
17년 전 조회 4,501
17년 전 조회 2,259
17년 전 조회 3,935
17년 전 조회 1,828
17년 전 조회 1,656
17년 전 조회 2,591
17년 전 조회 1,578
17년 전 조회 1,885
17년 전 조회 1,743
17년 전 조회 2,813
17년 전 조회 1,766
17년 전 조회 1,357
17년 전 조회 1,509
17년 전 조회 3,402
17년 전 조회 2,431
17년 전 조회 2,224
17년 전 조회 1,487
17년 전 조회 2,711
17년 전 조회 1,441
17년 전 조회 1,408
17년 전 조회 1,657
17년 전 조회 3,017
17년 전 조회 2,676
17년 전 조회 2,728