一起学习网 一起学习网


Iframe自适应其加载的内容高度

网络编程 Iframe自适应其加载的内容高度 06-21
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>
<meta name='author' content='站长中国 http://www.zzcn.net/'>
<title>iframe自适应加载的页面高度</title>
</head>

<body>
<iframe src="child.htm"></iframe>
</body>
</html>

child.htm:

<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>
<meta name='author' content='站长中国 http://www.zzcn.net/'>
<title>iframe 自适应其加载的网页(多浏览器兼容)</title>
<script language=javascript>
function iframeAutoFit()
{
try
{
if(window!=parent)
{
var a = parent.document.getElementsByTagName("IFRAME");
for(var i=0; i<a.length; i++) //author:meizz
{
if(a[i].contentWindow==window)
{
var h = 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);
else window.addEventListener('load', iframeAutoFit, false);
</script>
</head>
<body>
<div style="width: 200; height: 400; background-color: yellow">
iframe 自适应其加载的网页(多浏览器兼容)
</div>
</body>
</html>

固定右栏宽度, 左栏内容先出现同时自适应宽度的布局
工作原理#wrapper必须触发hasLayout,不然有时里面的内容会浮得怪怪的,我直接用float的,可以用其他方式。其实如果只是要做到这个例子要的效果连#wrapper

转载未知大小的图片在一个已知大小容器中的水平和垂直居中(二)
这是一个未知大小的图片在一个已知大小容器中的水平和垂直居中的例子,原文标题:Centeringanimageofunknownsizeinanoutercontainerofknownsize,作者:StuNichollsform

IE Bug--浮动对象外补丁的双倍距离的解决方法
TheIEDoubledFloat-MarginBugIEBug--浮动对象外补丁的双倍距离先看以下代码:#box{background:ThreedFace;width:500px;height:400px;}#box1{float:left;background:#F2F2F2;width:300px;height:2


编辑:一起学习网

标签:自适应,大小,加载,双倍,在一