[JavaScript] jquery修改iframe尺寸以适应其内容 →→→→→进入此内容的聊天室

来自 , 2021-03-04, 写在 JavaScript, 查看 99 次.
URL http://www.code666.cn/view/417fbbf2
  1. <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js?ver=1.3.2'></script>
  2. <script type='text/javascript'>
  3.    
  4.     $(function(){
  5.    
  6.         var iFrames = $('iframe');
  7.      
  8.         function iResize() {
  9.        
  10.                 for (var i = 0, j = iFrames.length; i < j; i++) {
  11.                   iFrames[i].style.height = iFrames[i].contentWindow.document.body.offsetHeight + 'px';}
  12.             }
  13.            
  14.                 if ($.browser.safari || $.browser.opera) {
  15.                
  16.                    iFrames.load(function(){
  17.                        setTimeout(iResize, 0);
  18.                });
  19.            
  20.                    for (var i = 0, j = iFrames.length; i < j; i++) {
  21.                                 var iSource = iFrames[i].src;
  22.                                 iFrames[i].src = '';
  23.                                 iFrames[i].src = iSource;
  24.                }
  25.                
  26.                 } else {
  27.                    iFrames.load(function() {
  28.                        this.style.height = this.contentWindow.document.body.offsetHeight + 'px';
  29.                    });
  30.                 }
  31.        
  32.         });
  33.  
  34. </script>
  35.  
  36.  
  37. //javascript/4297

回复 "jquery修改iframe尺寸以适应其内容"

这儿你可以回复上面这条便签

captcha