手机
当前位置:查字典教程网 >网页设计 > 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自适应其加载的内容高度】相关文章:

chrome居中但ie不居中的解决方法

Div+CSS布局入门

css cursor 的可选值

最全的CSS浏览器兼容问题

CSS盒模型制定网页的宽度和高度的原理

Iframe高度自适应代码

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

CSS布局——左定宽度右自适应宽度并且等高布局

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

Div与table的区别在速度和加载与网页应用等等中的差别介绍

精品推荐
分类导航