手机
当前位置:查字典教程网 >网页设计 > Div+Css教程 >Iframe自适应其加载的内容高度
Iframe自适应其加载的内容高度
摘要:iframe自适应加载的页面高度child.htm:iframe自适应其加载的网页(多浏览器兼容)functioniframeAutoFit...

<html>

<head>

<metahttp-equiv='Content-Type'content='text/html;charset=gb2312'>

<metaname='author'content='站长中国http://www.zzcn.net/'>

<title>iframe自适应加载的页面高度</title>

</head>

<body>

<iframesrc="child.htm"></iframe>

</body>

</html>

child.htm:

<html>

<head>

<metahttp-equiv='Content-Type'content='text/html;charset=gb2312'>

<metaname='author'content='站长中国http://www.zzcn.net/'>

<title>iframe自适应其加载的网页(多浏览器兼容)</title>

<scriptlanguage=javascript>

functioniframeAutoFit()

{

try

{

if(window!=parent)

{

vara=parent.document.getElementsByTagName("IFRAME");

for(vari=0;i<a.length;i++)//author:meizz

{

if(a[i].contentWindow==window)

{

varh=document.body.scrollHeight;

if(document.all){h+=4;}

if(window.opera){h+=1;}

a[i].style.height=h;

}

}

}

}

catch(ex)

{

alert("脚本无法跨域操作!");

}

}

if(document.attachEvent)window.attachEvent("onload",iframeAutoFit);

elsewindow.addEventListener('load',iframeAutoFit,false);

</script>

</head>

<body>

<divstyle="width:200;height:400;background-color:yellow">

iframe自适应其加载的网页(多浏览器兼容)

</div>

</body>

</html>

【Iframe自适应其加载的内容高度】相关文章:

大图片根据分辨率自适应宽度仍居中显示

pre标记里内容自动换行

css cursor 的可选值

自适应宽度的div+css示例

火狐浏览器中DIV的高度不随里面的内容增高而增高

最全的CSS浏览器兼容问题

css自动换行的技巧

Div+CSS布局入门

有趣的16进制颜色网站

兼容FIREFOX下背景层的自适应高度

精品推荐
分类导航