>  기사  >  웹 프론트엔드  >  contentWindow, contentDocument_기본 지식에 대한 심층 분석

contentWindow, contentDocument_기본 지식에 대한 심층 분석

WBOY
WBOY원래의
2016-05-16 17:30:111889검색

인생은 언제나 큰 염료통이다. 흰 천이 나가면 검은 천이 나온다.
contentWindow는 다양한 브라우저와 호환되며 자식 창의 창 개체를 얻을 수 있습니다.
contentDocument Firefox 지원, > 자식 창의 문서 개체를 얻을 수 있습니다.
하위 iframe에서 상위 iframe 또는 손자 iframe 높이를 설정합니다.

코드 복사 코드는 다음과 같습니다.

function showIframeH(){
var parentWin = parent.document.getElementById("test");
if(!parentWin) return false;
var sub = parentWin.contentWindow.document.getElementById("test2");
if (!sub ) return false;
var thirdHeight = sub.contentWindow.document.body.offsetHeight; //세 번째 레이어 본문 객체
sub.height = thirdHeight; //두 번째 레이어 iframe의 높이 설정
var secondHeight = x.contentWindow.document.body.offsetHeight; //두 번째 레이어 본문 객체
x.height = secondHeight; //첫 번째 레이어의 높이 설정
//alert(secondHeight);
/ /alert('body: ' x.contentDocument.body.offsetHeight ' div:' thirdHeight);
}

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.