zoukankan      html  css  js  c++  java
  • 自动适应Iframe

    function iframeAutoFit()
                {
                  try
                  {
                    if(window!=parent)
                    {
                      var a = parent.document.getElementsByTagName("IFRAME");
                      for(var i=0; i<a.length; i++) //www.deepteach.com
                      {
                        if(a[i].contentWindow==window)
                        {
                          var h = document.body.scrollHeight;
                          if(document.all) {h += 4;}
                          if(window.opera) {h += 1;}
                          a[i].style.height = h;
                        }
                      }
                    }
                  }
                  catch (ex)
                  {
                    alert("脚本无法跨域操作!");
                  }
                }
                //在子页面中增加
                if(document.attachEvent)
                  window.attachEvent("onload",  iframeAutoFit);
                else
                  window.addEventListener('load',  iframeAutoFit,  false);
  • 相关阅读:
    android开发 软键盘出现后 防止EditText控件遮挡 总体平移UI
    jQuery中this与$(this)的差别
    纯手写wcf代码,wcf入门,wcf基础教程
    JavaScript权威指南第01章 JavaScript 概述
    Python
    微信支付界面中文乱码问题
    EasyUI基础入门之Pagination(分页)
    Maximum Subarray
    CF1063F String Journey
    排序
  • 原文地址:https://www.cnblogs.com/yinchengliang/p/2593093.html
Copyright © 2011-2022 走看看