zoukankan      html  css  js  c++  java
  • JS获取IFRAME内容高度

    var ifr = this.create("iframe");//自定义创建IFRAME的方法
    ifr.src = "HTMLPage.htm";

    if (ifr.attachEvent) {//IE
    ifr.attachEvent("onload", function() {
    setTimeout(function() { ifr.css({ height: ifr.contentWindow.document.body.scrollHeight + 'px' }); }, 100);
    });
    } else {
    ifr.onload = function() {
    setTimeout(function() {
    ifr.css({ height: ifr.contentWindow.document.body.scrollHeight + 'px' });//自定义的方法
    }, 100);
    }
    }
    ifr.appendTo(document.body);//自定义的方法,将IFRAME添加到页面

    以上是案例,创建了IFRAME,并设置IFRAME的高度

    获取高度:document.getElementById('Iframe的ID').contentWindow.document.body.scrollHeight;

  • 相关阅读:
    python sys 模块
    python os 模块
    JS Dictionary
    JS Array
    JS String
    JS面向对象
    WPF中INotifyPropertyChanged用法与数据绑定
    JS的函数
    JS类型转换
    JS变量的作用域
  • 原文地址:https://www.cnblogs.com/554006164/p/2323377.html
Copyright © 2011-2022 走看看