六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 125|回复: 0

Iframe自适应高度控制

[复制链接]

升级  82.4%

290

主题

290

主题

290

主题

进士

Rank: 4

积分
912
 楼主| 发表于 2013-2-7 20:33:29 | 显示全部楼层 |阅读模式
<iframe width="778" align="center" height="200" id="cwin" name="cwin"  frameborder="0" scrolling="no"></iframe>
JS代码:
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;       else if(cwin.Document && cwin.Document.body.scrollHeight)        cwin.height = cwin.Document.body.scrollHeight;    }  }}

在iframe里面显示的页面,还要加点这样的样式控制:
<style type="text/css">        html, body        {            overflow-x: hidden;            overflow: auto;            margin: 0px;            height: 100%;        }    </style>
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表