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

<!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>
posted @ 2009-09-12 11:45  awp110  阅读(436)  评论(0编辑  收藏  举报