Home > Web Front-end > JS Tutorial > In-depth analysis of contentWindow, contentDocument_basic knowledge

In-depth analysis of contentWindow, contentDocument_basic knowledge

WBOY
Release: 2016-05-16 17:30:11
Original
1950 people have browsed it

Life is always a big dye vat. When a piece of white cloth goes out, black cloth comes out. When a piece of black cloth goes out, a piece of seven-color cloth comes out.
contentWindow is compatible with various browsers and can obtain the window object of the child window.
contentDocument Firefox support, > IE8 support. The document object of the child window can be obtained.
Set the parent iframe or grandchild iframe height in the child iframe.

Copy code The code is as follows:

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; //Third layer body object
sub.height = thirdHeight; //Set the height of the second layer iframe
var secondHeight = x.contentWindow.document.body.offsetHeight; //Second layer body object
x.height = secondHeight; //Set the height of the first layer iframe
//alert(secondHeight);
/ /alert('body: ' x.contentDocument.body.offsetHeight ' div:' thirdHeight);
}

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template