<cite id="ft77x"><strike id="ft77x"><listing id="ft77x"></listing></strike></cite><menuitem id="ft77x"></menuitem>
<var id="ft77x"></var><ins id="ft77x"><span id="ft77x"></span></ins>
<ins id="ft77x"><th id="ft77x"></th></ins>
<var id="ft77x"><dl id="ft77x"></dl></var>
<var id="ft77x"></var>
<cite id="ft77x"><strike id="ft77x"><listing id="ft77x"></listing></strike></cite>
<var id="ft77x"><strike id="ft77x"><listing id="ft77x"></listing></strike></var>
<var id="ft77x"></var>
<var id="ft77x"></var>
<cite id="ft77x"></cite>

怎樣讓超過iframe框架高度限定自動隱藏呢?

發布時間:2014-04-17 發布者: 點擊:

首頁>建站常識

 小編近在排版時發現iframe框架中的表單超過其框架高度后不知道應該怎么被自動隱藏,相信也有其他朋友同樣遇到過這種問題,那么我們就一起來探究下應該怎樣實現這個問題吧,以下是小編經過千辛萬苦(有點夸大了啊,嘻嘻)才找到的一個解決方法:

 
<script type="text/javascript">
 $(document).ready(function()
  {
   // Set specific variable to represent all iframe tags.
   var iFrames = document.getElementsByTagName_r('iframe');
 
   // Resize heights.
   function iResize()
   {
    // Iterate through all iframes in the page.
    for (var i = 0, j = iFrames.length; i < j; i++)
    {
     // Set inline style to equal the body height of the iframed content.
     iFrames[i].style.height = iFrames[i].contentWindow.document.body.offsetHeight + 'px';
    }
   }
 
   // Check if browser is Safari or Opera.
   if ($.browser.safari || $.browser.opera)
   {
    // Start timer when loaded.
    $('iframe').load(function()
     {
      setTimeout(iResize, 0);
     }
    );
 
    // Safari and Opera need a kick-start.
    for (var i = 0, j = iFrames.length; i < j; i++)
    {
     var iSource = iFrames[i].src;
     iFrames[i].src = '';
     iFrames[i].src = iSource;
    }
   }
   else
   {
    // For other good browsers.
    $('iframe').load(function()
     {
      // Set inline style to equal the body height of the iframed content.
      if(this.contentWindow.document.body.offsetHeight>1000)
      {
       this.style.height = 700 + 'px';//此處為小高度的設置
      }else{
       this.style.height = this.contentWindow.document.body.offsetHeight + 'px';
      }
     }
    );
   }
  }
 );
 
</script>
看的懂么?哈哈,其實也不用看懂,只要把上述文件外加一個jquery文件一起加載下,你會發現你想要的效果已經出現了...
以上信息來自鄭州啟凡網絡,鄭州啟凡計算機軟件有限公司專注于 營銷型網站建設 、SEO整合推廣、企業形象網站建設、行業網站建設、綜合商城建設、,品牌解決方案。
相關推薦文章