星空网 > 软件开发 > 网页设计

兼容firefox的iframe高度自适应代码

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

JavaScript部分:

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

<script type="text/javascript"> 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;  } } } } </script> 

  


html部分:

折叠

<iframe name="frameContent" src='/images/loading.gif' data-original="*" frameborder="0" width="100%" onload="SetCwinHeight(this)"></iframe> 

  


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




原标题:兼容firefox的iframe高度自适应代码

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

德国VAT申报指南把握税务步骤避免税务风险:https://www.kjdsnews.com/a/1387917.html
德国VAT申报指南完整流程一步步走:https://www.kjdsnews.com/a/1387918.html
德国VAT申报指南一步一步进入申报入口:https://www.kjdsnews.com/a/1387919.html
德国VAT申报指南一步一步走向成功:https://www.kjdsnews.com/a/1387920.html
德国VAT申报失误,可以重新申报吗?:https://www.kjdsnews.com/a/1387921.html
德国VAT申报失误可否重新申报?:https://www.kjdsnews.com/a/1387922.html
彻底乱了!全国大罢工!商业活动或遭重创!出货需谨慎...:https://www.kjdsnews.com/a/1842097.html
去普吉岛旅游要多少钱(详解普吉岛旅游费用及注意事项):https://www.vstour.cn/a/407238.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流