Life is always a large dyeing vat, with a piece of white cloth falling down, a piece of black cloth falling down, and a piece of seven-color cloth falling down.
contentWindow is compatible with each browser 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 in the child iframe, or the grandchild iframe height.
function showIframeH(){ var parentWin = ("test"); if(!parentWin) return false; var sub = ("test2"); if(!sub) return false; var thirdHeight = ; //The third layer body object = thirdHeight; //Set the height of the second layer iframe var secondHeight = ; //The second layer body object = secondHeight; //Set the height of the first layer iframe //alert(secondHeight); //alert('body: ' + + ' div:' + thirdHeight); }
An example is attached below. Because of the promotion of 2345, many navigation sites directly change the URL to the promotion page of 2345. That is, the width in 2345 is obtained under the current domain name, and then the height of the iframe content is set through js. This looks like a whole, and the core content is as follows
iframe
<body>
<iframe onload="mainFrameLoaded(this)" scrolling="no" src="https:///"></iframe>
js code
<script> function mainFrameLoaded(t) { //debugger; //alert(); = + 'px'; } </script>
Remember that js is written in front and iframe is located in the back, and it is triggered when loading through onload, perfect integration.