Assume that the main page has a div with an iframe placed inside
< ;div id="frameBox">
3 menu links, loading 1.html, 2.html, 3.html respectively in the iframe pages.
The three sub-pages are executed after window.onload is loaded on their own pages respectively
function aa(){
var newHeight = document.body.scrollHeight 20 "px";
window.parent.document.getElementById("frameBox").style.height = newHeight;
//The above firefox passes, but the following sentence must be added to ie6, otherwise the iframe height will be changed, but the visible area will not change
window.parent.document.getElementById("frameWin").style.height = newHeight;
}
The following method only needs to put the code on the main page:
Page code:
js script (added to the main page):
function test2(){
var frameWin = document.getElementById("frameWin");
var frameBox = document.getElementById("frameBox");
var newHeight;
if (frameWin.Document){
newHeight = frameWin.Document.body.scrollHeight 20 "px";
}else{
newHeight = frameWin.contentDocument.body.scrollHeight 20 "px";
}
frameWin.style.height = newHeight;
frameBox.style.height = newHeight;
}