b

iframe 의 크기를 자동으로 지정

bbking
· 20년 전 · 3923 · 1
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> Sample Script </title>
<meta name="Generator" content="EditPlus">


<!-- [1단계] 아래의 코드를 <head> 와 </head> 사이에 붙여 넣으세요 -->


<script type="text/javascript">

var iframeids=["myframe"] // iframe 에 사용할 ID 를 지정 해 주세요

var iframehide="yes"

function resizeCaller() {
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){
if (document.getElementById)
resizeIframe(iframeids[i])
if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
tempobj.style.display="block"
}
}
}

function resizeIframe(frameid){
var currentfr=document.getElementById(frameid)
if (currentfr && !window.opera){
currentfr.style.display="block"
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight;
else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
if (currentfr.addEventListener)
currentfr.addEventListener("load", readjustIframe, false)
else if (currentfr.attachEvent)
currentfr.attachEvent("onload", readjustIframe)
}
}

function readjustIframe(loadevt) {
var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot)
resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url){
if (document.getElementById)
document.getElementById(iframeid).src=url
}

if (window.addEventListener)
window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
window.attachEvent("onload", resizeCaller)
else
window.onload=resizeCaller

</script>


<!----------------- 여기까지 ----------------->

</head>

<body>

<!-- [2단계] 아래의 방법으로 iframe 태그를 넣으세요 -->

<iframe id="myframe" src="http://www.naver.com" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" style="overflow:visible; width:100%; display:none"></iframe>

<!-- 여기에서 주의할 점은 스크립트의 맨 처음에 지정한 iframe 의 아이디를 반드시 사용해야 한다는 점입니다 --->

<!----------------- 여기까지 ----------------->

<p>
위의 페이지는 iframe 태그에 의해 불려진 페이지의 전체 입니다<br>
이처럼 이 스크립트를 사용하면 불려질 문서의 길이가 자동으로 체크되어 그 길이만큼 iframe 이 보여집니다

</body>
</html><div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 17:16:08 PHP & HTML에서 이동 됨]</div>
|

댓글 1개

써먹어야될곳이 생각났네요
감사합니다
댓글을 작성하시려면 로그인이 필요합니다. 로그인

개발자팁

개발과 관련된 유용한 정보를 공유하세요. 질문은 QA에서 해주시기 바랍니다.

+
분류 제목 글쓴이 날짜 조회
기타
bbbking
20년 전 조회 4,001
JavaScript 20년 전 조회 5,596
Linux 20년 전 조회 5,226
MySQL 20년 전 조회 5,119
기타 20년 전 조회 5,815
기타 20년 전 조회 7,333
기타 20년 전 조회 7,524
JavaScript
bbbking
20년 전 조회 3,246
기타
bbbking
20년 전 조회 2,916
JavaScript
bbbking
20년 전 조회 3,473
기타
bbbking
20년 전 조회 4,638
기타
bbbking
20년 전 조회 3,799
기타
bbbking
20년 전 조회 5,732
기타 20년 전 조회 4,472
기타
bbbking
20년 전 조회 3,924
JavaScript
bbbking
20년 전 조회 1.9만
Flash 20년 전 조회 7,700
기타 20년 전 조회 4,147
기타 20년 전 조회 6,930
기타 20년 전 조회 3,865
기타 20년 전 조회 4,128
기타 20년 전 조회 3,638
기타 20년 전 조회 4,058
기타 20년 전 조회 4,035
기타 20년 전 조회 3,779
JavaScript
[JavaScript]
20년 전 조회 3,892
기타 20년 전 조회 4,282
기타 20년 전 조회 5,056
JavaScript 20년 전 조회 5,212
PHP 20년 전 조회 5,490
🐛 버그신고