找到一款可以自适应浏览器大小的js,对于iframe特别好用
2015-01-30 10:13
411 查看
使用代码如下
<html>
<head>
<script>
function SetCwinHeight(obj)
{
var cwin=obj;
if (document.getElementById)
{
if (cwin && !window.opera)
{
if (cwin.contentDocument && cwin.contentDocument.body.offsetHeight)
cwin.height = cwin.contentDocument.body.offsetHeight + 20; //FF NS
else if(cwin.Document && cwin.Document.body.scrollHeight)
cwin.height = cwin.Document.body.scrollHeight + 10;//IE
}
else
{
if(cwin.contentWindow.document && cwin.contentWindow.document.body.scrollHeight)
cwin.height = cwin.contentWindow.document.body.scrollHeight;//Opera
}
}
}
</script>
</head>
<body>
<iframe src="你引用的页面.html" onload="SetCwinHeight(this);" width="600px">
</body>
</html>
<html>
<head>
<script>
function SetCwinHeight(obj)
{
var cwin=obj;
if (document.getElementById)
{
if (cwin && !window.opera)
{
if (cwin.contentDocument && cwin.contentDocument.body.offsetHeight)
cwin.height = cwin.contentDocument.body.offsetHeight + 20; //FF NS
else if(cwin.Document && cwin.Document.body.scrollHeight)
cwin.height = cwin.Document.body.scrollHeight + 10;//IE
}
else
{
if(cwin.contentWindow.document && cwin.contentWindow.document.body.scrollHeight)
cwin.height = cwin.contentWindow.document.body.scrollHeight;//Opera
}
}
}
</script>
</head>
<body>
<iframe src="你引用的页面.html" onload="SetCwinHeight(this);" width="600px">
</body>
</html>
相关文章推荐
- 【JS】滚动图代码,可以调节速度,调节大小,兼容所有浏览器
- table+div+iframe打造高度自适应的后台布局框架(需要用JS控制大小)
- 使iframe高度和宽度适应浏览器可视区域大小
- 真正的让iframe自适应高度 兼容多种浏览器随着窗口大小改变
- Resize Window一款可以切换浏览器屏幕分辨率大小的浏览器插件
- 让iframe自适应高度 兼容多种浏览器随着窗口大小改变
- js监视浏览器窗口大小变化,使元素适应窗口大小
- iframe切换内容页仍然能自适应大小代码(含js)
- 真正的让iframe自适应高度 兼容多种浏览器随着窗口大小改变
- 真正的让iframe自适应高度 兼容多种浏览器随着窗口大小改变
- 真正的让iframe自适应高度 兼容多种浏览器随着窗口大小改变
- 真正的让iframe自适应高度 兼容多种浏览器随着窗口大小改变
- 特别实用的-js判断浏览器窗体、用户屏幕可视区域大小位置的方法
- table+div+iframe打造高度自适应的后台布局框架(需要用JS控制大小)
- 用js自适应iframe的大小
- 如何使IFrame的长宽与内容自动适应大小
- 如何使IFrame的长宽与内容自动适应大小
- 如何使IFrame的长宽与内容自动适应大小
- 如何使IFrame的长宽与内容自动适应大小
- 如何使IFrame的长宽与内容自动适应大小