var admin = {
// 计算页面最大宽高值
size : function()
{
var a, yc;
var b, wh, pw, ph;
a = window.innerHeight && window.scrollMaxY
? document.body.scrollWidth
: document.body.scrollHeight > document.body.offsetHeight
? document.body.scrollWidth
: document.body.offsetWidth;
yc = window.innerHeight && window.scrollMaxY
? (window.innerHeight + window.scrollMaxY)
: document.body.scrollHeight > document.body.offsetHeight
? document.body.scrollHeight
: document.body.offsetHeight;
b = self.innerHeight ? self.innerWidth : document.documentElement
&& document.documentElement.clientHeight
? document.documentElement.clientWidth
: document.body.clientWidth;
wh = self.innerHeight ? self.innerHeight : document.documentElement
&& document.documentElement.clientHeight
? document.documentElement.clientHeight
: document.body.clientHeight;
ph = yc < wh ? wh : yc;
pw = a < b ? b : a;
return new Array(pw, ph, a, yc)
},
// 增加监听事件
addEvent: function(o, a, b) {
o.attachEvent ? o.attachEvent('on' + a, function() {
b.call(o)
}) : o.addEventListener(a, b, false)
},
//iframe 跟其中内嵌页面高度重设iframe高度
init: function() {
var k = parent.document.getElementById('bodycontent');
k.style.height = 20+'px';
var o = admin.size();
//这个ID是它上面包含它那个iframe的 ID
if (!k)
{
return;
}
//alert(o[1]);
k.style.height = o[1] + 'px';
}
}
//为 window 对像增加一个方法(iframe高度重新计算)
admin.addEvent(window, 'load', admin.init);
使用时,只需要加载此文件即可。