DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Implement Function.apply( ) In IE 4 & 5
IE 4 & 5 don't implement Function.apply( ).
This workaround is based on code by Aaron Boodman.
Quoted from JavaScript,the Definitive Guide,5th edition
if (!Function.prototype.apply) {
Function.prototype.apply = function(object, parameters) {
var f = this;
var o = object || window;
var args = parameters || [];
o._$_apply_$_ = f;
var stringArgs = [];
for(var i = 0; i < args.length; i++)
stringArgs[i] = "args[" + i + "]";
var arglist = stringArgs.join(",");
var methodcall = "o._$_apply_$_(" + arglist + ");";
var result = eval(methodcall);
delete o._$_apply_$_;
return result;
};
}




