ifream子页面高度问题

/监测ifream高度/
父页面添加一下代码用以检测子页面高度 使用ifream的load()方法检测子页面高度发生变化时候触发事件 每次给ifream的容器重新赋予高度
(function ($, window, undefined) {
var elems = $([]),
jq_resize = $.resize = . e x t e n d ( .extend( .extend(.resize, {}),
timeout_id,
str_setTimeout = ‘setTimeout’,
str_resize = ‘resize’,
str_data = str_resize + ‘-special-event’,
str_delay = ‘delay’,
str_throttle = ‘throttleWindow’;
jq_resize[str_delay] = 250;
jq_resize[str_throttle] = true;
$.event.special[str_resize] = {
setup: function () {
if (!jq_resize[str_throttle] && this[str_setTimeout]) {
return false;
}
var elem = $(this);
elems = elems.add(elem);
$.data(this, str_data, {
w: elem.width(),
h: elem.height()
});
if (elems.length === 1) {
loopy();
}
},
teardown: function () {
if (!jq_resize[str_throttle] && this[str_setTimeout]) {
return false;
}
var elem = $(this);
elems = elems.not(elem);
elem.removeData(str_data);
if (!elems.length) {
clearTimeout(timeout_id);
}
},
add: function (handleObj) {
if (!jq_resize[str_throttle] && this[str_setTimeout]) {
return false;
}
var old_handler;

        function new_handler(e, w, h) {
            var elem = $(this),
                data = $.data(this, str_data);
            data.w = w !== undefined ? w : elem.width();
            data.h = h !== undefined ? h : elem.height();
            old_handler.apply(this, arguments);
        }

        if ($.isFunction(handleObj)) {
            old_handler = handleObj;
            return new_handler;
        } else {
            old_handler = handleObj.handler;
            handleObj.handler = new_handler;
        }
    }
};

function loopy() {
    timeout_id = window[str_setTimeout](function () {
        elems.each(function () {
            var elem = $(this),
                width = elem.width(),
                height = elem.height(),
                data = $.data(this, str_data);
            if (width !== data.w || height !== data.h) {
                elem.trigger(str_resize, [data.w = width, data.h = height]);
            }
        });
        loopy();
    }, jq_resize[str_delay]);
}

})(jQuery, this);
大致思路如下:如看不懂请联系qq502252328

$("#ifream").contents().find(“html”).resize(function(){
})

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值