iframe自适应高度,自动变长或变短

    <script language="javascript">
        function changeIframeHeight(){
            var ifm = document.getElementById("contentIframe");
            try{
               var brow = $.browser;
                var subWeb = document.frames?document.frames["contentIframe"].document:ifm.contentDocument;
                var html = ifm.contentWindow.document.documentElement;
                if(brow.msie){
                 if(ifm != null && subWeb != null){
                     ifm.height = (subWeb.body.scrollHeight+10)+"px";
                 }
                }else{
                   if(html!=null){
                      ifm.height = html.offsetHeight+"px";
                   }
                }

            }catch (ex){}
   
        }
    </script>

  <iframe onload="try{changeIframeHeight();}catch(e){}" id="contentIframe" name="contentIframe" style="width:99%;"
               class="iframeStyle" scrolling="no"  frameborder=0 src="${rightUrl!}"></iframe>

猜你喜欢

转载自zhousheng193.iteye.com/blog/2283872
今日推荐