여기 하나의 방법입니다 .
<html>
<head> <title>Parent frame</title> </head>
<body onload="window.setTimeout(resizeFrame, 250)" bgcolor="#cccccc">
<script type="text/javascript">
// Firefox worked fine. Internet Explorer shows scrollbar because of frameborder
function resizeFrame() {
var f = document.getElementById('childframe');
if (f.style.height != f.contentWindow.document.body.scrollHeight + "px")
f.style.height = f.contentWindow.document.body.scrollHeight;
window.setTimeout(resizeFrame, 250)
}
</script>
<p>Parent frame.</p>
<p>Parent frame.</p>
<p>Parent frame.</p>
<p>Parent frame.</p>
<p>
<iframe frameborder=0 src="./innerframe.htm" name="childframe" id="childframe">
</iframe>
</p>
</body>
</html>
참고 :이처럼 당신이 다른 도메인의 내용을 당겨 있기 때문에 당신이 프레임을 사용하고 있으리라 믿고있어. 동일한 도메인에서 콘텐츠를 가져 오는 경우 XmlHttpRequest를 사용하여 콘텐츠를 가져온 다음 스크립트를 사용하여 상위 페이지의 DIV에 HTML을 삽입 할 수 있습니다. 브라우저의 사이트 간 스크립팅 제한으로 인해 콘텐츠가 다른 도메인에있는 경우에는이 작업을 수행 할 수 없습니다.
dani, 내 개정 된 답변이 당신이하려는 것과 일치합니까? –
글쎄, 나는 타이머를 사용하고 싶지 않다. 효율적이지 않다. – dani