웹마스터 팁
page_full_width" class="col-xs-12" |cond="$__Context->page_full_width">
다른 도메인간 iframe 크기 자동조절(cross domain iframe auto resize)
2008.04.24 13:21
참고하세요...
a.com이라는 도메인에서 b.com의 b.html을 불러올때.. 크기를 자동으로 조절하기 위한 방법입니다.
먼저 a라는 홈페이지에 auto_size.html을 만듭니다.
====================== auto_size.html - a.com =========================
<html>
<head>
<title>Resizing Page</title>
<script type="text/javascript">
function onLoad() {
var params = window.location.search.substring( 1 ).split( '&' );
var height;
for( var i = 0, l = params.length; i < l; ++i ) {
var parts = params[i].split( '=' );
switch( parts[0] ) {
case 'height':
height = parseInt( parts[1] );
break;
}
}
if( typeof( height ) == 'number' ) {
window.top.updateIFrame( height );
}
}
window.onload = onLoad;
</script>
</head>
<body>
<p>Resizing IFrame...</p>
</body>
</html>
=======================================================
그리고 a라는 홈페이지에서 링크할 문서에는 아래와 같이 삽입합니다.
======================= a.html - a.com ===================
<script type="text/javascript">
function updateIFrame( height ) {
var iframe = document.getElementById( 'myiframe' );
iframe.setAttribute( '+ 'height', height );
}
</script>
<iframe id="myiframe" src="http://b.com/b.html" scrolling=no frameborder=0 width="600" height="600"></iframe>
이제 b라는 도메인의 b.html에는 아래와 같이 삽입합니다.
================== b.html - b.com============================
<style>
#inneriframe { position : absolute; top : 0px; left : 0px; visibility: hidden; }
</style>
<script type="text/javascript">
function rsize() {
var iframe = document.getElementById( 'inneriframe' );
var wrapper = document.getElementById( 'wrapper' );
var height = Math.max( document.body.offsetHeight, document.body.scrollHeight );
iframe.src = 'http://a.com/auto_size.html?height='+height; }
</script>
<body onload=rsize(); >
<div id=wrapper>
내용
</div>
<iframe id="inneriframe" width="10" height="10"></iframe>
</body>
a.com이라는 도메인에서 b.com의 b.html을 불러올때.. 크기를 자동으로 조절하기 위한 방법입니다.
먼저 a라는 홈페이지에 auto_size.html을 만듭니다.
====================== auto_size.html - a.com =========================
<html>
<head>
<title>Resizing Page</title>
<script type="text/javascript">
function onLoad() {
var params = window.location.search.substring( 1 ).split( '&' );
var height;
for( var i = 0, l = params.length; i < l; ++i ) {
var parts = params[i].split( '=' );
switch( parts[0] ) {
case 'height':
height = parseInt( parts[1] );
break;
}
}
if( typeof( height ) == 'number' ) {
window.top.updateIFrame( height );
}
}
window.onload = onLoad;
</script>
</head>
<body>
<p>Resizing IFrame...</p>
</body>
</html>
=======================================================
그리고 a라는 홈페이지에서 링크할 문서에는 아래와 같이 삽입합니다.
======================= a.html - a.com ===================
<script type="text/javascript">
function updateIFrame( height ) {
var iframe = document.getElementById( 'myiframe' );
iframe.setAttribute( '+ 'height', height );
}
</script>
<iframe id="myiframe" src="http://b.com/b.html" scrolling=no frameborder=0 width="600" height="600"></iframe>
이제 b라는 도메인의 b.html에는 아래와 같이 삽입합니다.
================== b.html - b.com============================
<style>
#inneriframe { position : absolute; top : 0px; left : 0px; visibility: hidden; }
</style>
<script type="text/javascript">
function rsize() {
var iframe = document.getElementById( 'inneriframe' );
var wrapper = document.getElementById( 'wrapper' );
var height = Math.max( document.body.offsetHeight, document.body.scrollHeight );
iframe.src = 'http://a.com/auto_size.html?height='+height; }
</script>
<body onload=rsize(); >
<div id=wrapper>
내용
</div>
<iframe id="inneriframe" width="10" height="10"></iframe>
</body>
댓글 2
-
드렁크수달
2009.04.06 22:04
테스트 해본 결과 아주 잘 되네요 ^^ 감사합니다.. 퍼가도 되겠죠 ^^ -
EveR™
2012.02.10 14:02
제이 쿼리가 훨 쉬울듯 하네요. ㅋㅋ
쌩 자바스크립트는 넘 어려워요 ㅠㅠ
제목 | 글쓴이 | 날짜 |
---|---|---|
윈도즈에서 PHP3와 MySQL 설치 [40] | zero | 2000.03.06 |
윈도즈에서의 Apahch 설치법 [88] | zero | 2000.03.06 |
MYSQL Query의 간단한 사용법 [82] | zero | 2000.03.06 |
PHP에서의 파일입출력 문법 (간단히) [92] | zero | 2000.03.06 |
간단한 PHP 문법 [204] | zero | 2000.03.06 |
Database, MySQL 이 무엇인가~~~ ^^ [103] | zero | 2000.03.06 |
PHP에 대한 소개 [216] | zero | 2000.03.06 |
웹서핑 동작 원리의 이해 [18] | zero | 2007.10.05 |
입력폼에 배경그림 넣기 [1] | 정낙훈(xynex) | 2008.12.23 |
구글 번역기 API | 유비키리 | 2008.10.29 |
전체크기로 새창 열기 [1] | ITBANK.kr | 2008.10.01 |
지정된 시간동안 강제로 보여지는 언론사에서 많이 사용하는 광고창 | ITBANK.kr | 2008.10.01 |
항상 같은곳에 있는 광고창 만들기 | ITBANK.kr | 2008.10.01 |
첨부파일 확장자 체크 [정규식] | arimaya | 2008.06.23 |
자파스크립트로 GET으로 넘어온 파라미터 가져오기 [1] | 중딩 | 2008.05.26 |
나만의 위지윅 웹에디터 만들기 - 기본 준비2 [2] | 예뜨락 | 2008.05.11 |
나만의 위지윅 웹에디터 만들기 - 기본 준비1 [3] | 예뜨락 | 2008.05.05 |
나만의 위지윅 웹에디터 만들기 - 글 쓰기에 앞서 [4] | 예뜨락 | 2008.05.05 |
다른 도메인간 iframe 크기 자동조절(cross domain iframe auto resize) [2] | 서기 | 2008.04.24 |
웹페이지에 마우스 따라다니는 예쁜 시계를 넣자 [5] | gosoo99 | 2008.04.08 |