现在的位置: 首页 > 综合 > 正文

iframe自适应父窗口高度改变兼容IE firefox

2012年04月10日 ⁄ 综合 ⁄ 共 742字 ⁄ 字号 评论关闭
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>iframe的自动适应高度</title>
</head>
<body>
<script type="text/javascript">
function SetCwinHeight(o){
if (document.getElementById){
   if (o && !window.opera){
    if (o.contentDocument && o.contentDocument.body.offsetHeight){
     o.height = o.contentDocument.body.offsetHeight;
    }else if(o.Document && o.Document.body.scrollHeight){
     o.height = o.Document.body.scrollHeight;
    }
   }
}
}
</script>
<iframe width="100%" id="o" onload="Javascript:SetCwinHeight(this)" height="1" frameborder="0" src="IFrame_myPage.aspx"></iframe>
这是内容及其它
</body>
</html>

抱歉!评论已关闭.