母版页+菜单+iFrame的完美解决
--------------------
| 母版 title |
--------------------
| |
|index | iframe
|menu | 内容页
| |
-------------------
| 母版 footer |
-------------------
点击左面菜单/tree,通过设置tree的navi-url,在右面的iframe动态加载内容页面。
iframe 要按内容页面 自动适应 自动调节高度 。
母版,菜单 比较好解决。
iFrame高度自动调节,好象是个难题耶。
GOOGLE一下,方法一大堆,有点太复杂,都不大行。
vs2008的帮助又动不了,连看个iframe类模型都无办法,菜啊。
试了N回,下面简单代码可以了,asp.net 2.0条件下。
<iframe id="content" name="content" scrolling="no" frameborder="0" width="754px" height="50px" onload = "height = this.Document.body.scrollHeight + 30;" > </iframe>
注意事项
1、height设为auto不行的,一定要有一个值
2、this.document引用到是的 iframe所在页面对象,
this.Document (大写D),才能引用到iframe内含对象
这个方法可能更稳妥
onload = "height = document.frames(this.name).document.body.scrollHeight + 30"
++++++++++++++++
上面的代码,自己试过,不行。下面是本人试过OK的版本,代码如下
/**
* 自动调整IFrame的高度
*/
function IFrameResize(){
//alert(this.document.body.scrollHeight); //弹出当前页面的高度
var obj = parent.document.getElementById("frame_content"); //取得父页面IFrame对象
// alert(obj.height); //弹出父页面中IFrame中设置的高度
obj.style.height = this.document.body.scrollHeight+100; //调整父页面中IFrame的高度为此页面的高度
//alert(obj.height);
}
window.οnlοad=function()
{
IFrameResize(); //改变 Iframe 高度
}