Iframe 自适应高度应用

来源:互联网 发布:钣金外壳 软件 编辑:程序博客网 时间:2024/06/11 12:38

方案一:parent.jsp

Script:

function iFrameHeight() {         var ifm= document.getElementById("iframepage");
        var subWeb = document.frames ? document.frames["iframepage"].document : ifm.contentDocument;
<span style="white-space:pre"></span>if(ifm != null && subWeb != null) {<span style="white-space:pre"></span>ifm.height = subWeb.body.scrollHeight;<span style="white-space:pre"></span>}}


HTML:

<iframe src="" marginheight="0" marginwidth="0" frameborder="0" scrolling="no" width="100%" height=100% id="iframepage" name="iframepage"  onLoad="iFrameHeight()"></iframe>

方案二:parent.jsp

Script:

function iFrameHeight(rSize) {if(undefined==rSize)return;        var ifm= document.getElementById("iframepage");ifm.height = rSize*150+(10-rSize)*10 ; //动态计算iframe页面有多少行,10-rSize 是由于底部无法显示全分页才加的        }

HTML:

<iframe src="" marginheight="0" marginwidth="0" frameborder="0" scrolling="no" width="100%" height=100% id="iframepage" name="iframepage"  ></iframe>


children.jsp

Script:

$(function(){
window.parent.iFrameHeight(${page.list.size()});
});



0 0
原创粉丝点击