javascript中iframe高度自适应(同域)实例详解-创新互联

javascript 中iframe高度自适应(同域)

创新互联公司专注于企业网络营销推广、网站重做改版、新和网站定制设计、自适应品牌网站建设、H5开发商城建设、集团公司官网建设、成都外贸网站建设、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为新和等各大城市提供网站开发制作服务。

      今天解决了iframe高度自适应的问题,不过这只是同域下的页面嵌入,以下是代码:

function SetCwinHeight(){

     var iframeid = document.getElementById("frame");  //frame是iframe的id

     if (document.getElementById) {
      if (iframeid && !window.opera) {
        if (iframeid.contentDocument && iframeid.contentDocument.body.offsetHeight) {

         iframeid.height = iframeid.contentDocument.body.offsetHeight;

        }else if (iframeid.Document && iframeid.Document.body.scrollHeight) {
         
         iframeid.height = iframeid.Document.body.scrollHeight;
         
        }
      }
     } 

另外有需要云服务器可以了解下创新互联建站www.cdcxhl.com,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


文章标题:javascript中iframe高度自适应(同域)实例详解-创新互联
网页地址:http://bzwzjz.com/article/ccdcsi.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 成都网站建设 成都网站设计 网站设计 网站设计 成都网站建设 手机网站建设套餐 成都企业网站制作 成都网站制作公司 成都网站设计 定制网站设计 专业网站建设 成都网站设计 外贸营销网站建设 成都网站建设流程 成都网站建设公司 成都网站建设 响应式网站设计 四川成都网站设计 成都网站制作 定制网站制作 成都网站制作 成都网站建设