Search

8/13/2008

fix-ie5.js扩展在IE5下不能使用的几个方法_应用技巧

fix-ie5.js扩展在IE5下不能使用的几个方法_应用技巧


// fix Function.apply
if (!Function.apply) {
var APPLY = "apply-" + Number(new Date);
$$apply = function(f, o, a) {
var r;
o[APPLY] = f;
switch (a.length) { // deconstruct for speed
case 0: r = o[APPLY](); break;
case 1: r = o[APPLY](a[0]); break;
case 2: r = o[APPLY](a[0], a[1]); break;
case 3: r = o[APPLY](a[0], a[1], a[2]); break;
case 4: r = o[APPLY](a[0], a[1], a[2], a[3]); break;
default:
var aa = [], i = a.length - 1;
do aa[i] = "a[" + i + "]"; while (i--);
eval("r=o[APPLY](" + aa + ")");
}
delete o[APPLY];
return r;
};
// fix ICommon
ICommon.valueOf.prototype.inherit = function() {
return $$apply(arguments.callee.caller.ancestor, this, arguments);
};
}

沒有留言: