日期:2014-05-18  浏览次数:20643 次

框架自适应的问题
现在项目已作完,还有个问题,就是
      左边有个菜单,选择菜单,流览器,的滚动条长度就增加,
      相当于框架没有自适应大小变化,
      如何解决这个问题,给段代码,啊

------解决方案--------------------
/*****************************************************************************
* iframe 自适应其加载的网页(多浏览器兼容)
* 例如:
* 使用注意: 用于iframe嵌入页,不是引用那个主页面
* 如果使用
* last update by applebomb 060525[from www.meizz.com]
*****************************************************************************/
var iframeAutoFitMinHeight = 0;
var iframeAutoFitMaxHeight = 99999999;
function iframeAutoFit(forceHeight)
{
var ex;
try
{
if(window!=parent)
{
var a = parent.document.getElementsByTagName( "IFRAME ");
for(var i=0; i <a.length; i++)
{
if(a[i].contentWindow==window)
{
var h;
if(forceHeight != null && typeof(forceHeight) == "number " && forceHeight > 0)
h = forceHeight;
else
{
var h1=0, h2=0;
if(document.documentElement&&document.documentElement.scrollHeight)
{
h1=document.documentElement.scrollHeight;
}
if(document.body)h2=document.body.scrollHeight;

h = Math.max(h1, h2);
if(iframeAutoFitMinHeight > h)
h = iframeAutoFitMinHeight;
if(h > iframeAutoFitMaxHeight)
h = iframeAutoFitMaxHeight;
}

// if(document.all) {h += 2;}
// if(window.opera) {h += 1;}
a[i].style.height = h + "px ";
return h;
}
}
}
}
catch (ex){
}
}

------解决方案--------------------
UP