送分题,关于IFRAME取对象值
网页a.htm,其中使用<IFRAME name="mainFrame" id="mainFrame" src='b.htm' style="height:400" width="100%" scrolling="no" noResize></IFRAME>
网页b.htm,其中
使用下面语句
parent.document.all.mainFrame.style.height=600
起作用。
在a.htm使用此语句也起作用。
parent.document.all.mainFrame.style.height=600
当然使用document.all.mainFrame.style.height=600也可以。
如何在b.htm中使用何语句,可实现iframe高度改变的结果,但在a.htm使用此语句无效。强调是独特的写法。
因为我在每个页面ONLOAD时都会执行一个函数。函数如下:
function window.onload() {
try {
parent.document.all.mainFrame.style.height=(document.body.scrollHeight<400)?400:document.body.scrollHeight;
}
catch(e) {
return false;
}
}