Bookmark and Share

Lee's 程序人生

HTML CSS Javascript XML AJAX ATLAS C# C++ 数据结构 软件工程 设计模式 asp.net Java 数字图象处理 Sql 数据库
  博客园  :: 首页  :: 新随笔  :: 联系 :: 管理

Iframe自适应高度_ie_firefox下都可用

Posted on 2008-06-13 10:13  analyzer  阅读(212)  评论(0)    收藏  举报
 1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
 2<html xmlns="http://www.w3.org/1999/xhtml">   
 3<head>   
 4<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />   
 5<title>iframe</title>   
 6</head>   
 7<body>   
 8<script type="text/javascript">   
 9 function SetCwinHeight(){    
10  var bobo=document.getElementById("bobo"); //iframe id    
11  if (document.getElementById){    
12   if (bobo && !window.opera){    
13    if (bobo.contentDocument && bobo.contentDocument.body.offsetHeight){    
14     bobobobo.height = bobo.contentDocument.body.offsetHeight;    
15    }
else if(bobo.Document && bobo.Document.body.scrollHeight){    
16     bobobobo.height = bobo.Document.body.scrollHeight;    
17    }
    
18   }
    
19  }
    
20 }
    
21
</script>   
22<iframe width="100%" id="bobo" onload="Javascript:SetCwinHeight()" height="1" frameborder="0" src="/default.asp?cateID=1"></iframe>   
23这里写几个字试试!子鼠!    
24</body>   
25</html>