第九区-Jquery超级群

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 362|回复: 0

jquery 计算iframe 高度问题 [复制链接]

Rank: 1

发表于 2011-7-8 18:27:13 |显示全部楼层
  1. <script type="text/javascript">

  2. $.ajaxSetup ({
  3. cache: false
  4. });


  5. $(function(){
  6.         $("#c-c-iframe").load(function(){               
  7.                 $(this).height($(this).contents().height());
  8.                 //$(this).height($(this).contents().find("body").attr('scrollHeight'));
  9.                  
  10.                 var mainheight = $(this).contents().find("html").height();
  11.                 ///if(mainheight < 400){
  12.                 //        mainheight = 400;
  13.                 //}
  14.                 $("#rightM").css("height",mainheight);
  15.                 $(".mainM").css("height",mainheight);
  16.                 alert(mainheight);
  17.                
  18.                
  19.         });
  20.        
  21. });




  22. </script>
复制代码
这是我的js代码



两个链接和iframe:

Java代码

  • <li><a href="selfinfo.jsp" target="c-c-iframe" title="个人信息" >个人信息</a></li>   
  • <li><a href="modifypass.jsp" target="c-c-iframe" title="修改密码" >修改密码</a></li>   
  •   
  • <iframe src="init.jsp" id="c-c-iframe" name="c-c-iframe" width="500px;"   frameborder="0" scrolling="no" marginwidth="0" marginheight="0"></iframe>  

<li><a href="selfinfo.jsp" target="c-c-iframe" title="个人信息" >个人信息</a></li> <li><a href="modifypass.jsp" target="c-c-iframe" title="修改密码" >修改密码</a></li>  <iframe src="init.jsp" id="c-c-iframe" name="c-c-iframe" width="500px;"  frameborder="0" scrolling="no" marginwidth="0" marginheight="0"></iframe>转自:http://www.javaeye.com/topic/281102

js代码:

Java代码

  • <script type="text/javascript">   
  • <!--   
  • $(function(){   
  •      $("#c-c-iframe").load(function(){            
  •          $(this).height($(this).contents().find("#content").height() + 40);   
  •      });   
  •         
  • });   
  • -->   
  • </script>  



我在网上在找的 这段代码


就是 实现 像framest的框架集的那种效果!

可是我每次 alert的值 火狐 是正常的 出来的值 是不同的


但 IE  就会出现 如果 第一次 是400   下次 还会计算还是 400  除非 iframe内部高度 大于400  就会出现大于400  但就是不会减小


我也不知道 我表达的清楚不清楚
望朋友们 多多 关照!





您需要登录后才可以回帖 登录 | 立即注册

Archiver|第九区-Jquery超级群    点击这里加入此群 点击这里加入此群

GMT+8, 2012-2-8 09:23 , Processed in 0.079866 second(s), 15 queries .

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部