好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

兼容firefox的iframe高度自适应代码_html/css_WEB-ITnose

网上关于iframe高度自适应的代码有很多,但比较杂乱,本文根据实用性整理了以下代码:

JavaScript部分:

折叠JavaScript Code复制内容到剪贴板

  function SetCwinHeight(iframeObj){ if (document.getElementById){ if (iframeObj){ if (iframeObj.contentDocument && iframeObj.contentDocument.body.offsetHeight){ iframeObj.height = iframeObj.contentDocument.body.offsetHeight; } else if (document.frames[iframeObj.name].document && document.frames[iframeObj.name].document.body.scrollHeight){ iframeObj.height = document.frames[iframeObj.name].document.body.scrollHeight;   } } } }    

  


html部分:

折叠XML/HTML Code复制内容到剪贴板

  

  


标记*号的地方填入iframe页面的地址。需要注意的是,src地址必须是在同一网站下,否则会出现“权限被禁止”的错误。

查看更多关于兼容firefox的iframe高度自适应代码_html/css_WEB-ITnose的详细内容...

  阅读:33次