방법 1 : 방법 1
코드 사본은 다음과 같습니다.
$ (window.parent.document) .find ( "#contentiframe"). load (function () {
var main = $ (window.parent.document) .find ( "#contentiframe");
var thisHeight = $ (document) .height ();
if (thishight <800)
thisheight = 800;
Main.height (Thishight);
});
이 작문 방법은로드시 고유 요소의 적응 높이에만 적응할 수 있습니다. 요소가 변경되면 (예를 들어 많은 요소를 추가하고, 높이가 변경된 후), 부모 형태의 iframe 높이를 제 시간에 변경할 수 없습니다.
방법 2 : 방법 2.
코드 사본은 다음과 같습니다.
함수 setMainHeight () {
var main = $ (window.parent.document) .find ( "#contentiframe");
var thisheight = $ ( "body"). height ();
if (thishight <800) {thisheight = 800; }
Main.height (Thishight+50);
settimeout (setMainHeight, 2000);
}
서브 페이지의 높이 변화를 결정하기 위해 투표에 타이머를 추가하십시오.
위의 두 가지 유형은 iframes에 의해 적응할 수 있습니다. 친구, 프로젝트 요구에 따라 자유롭게 선택하십시오.