Function.prototype's apply and call were only added in ECMA262 Edition3 released in 1999 (ECMA262 Edition2 was released in 1998). In previous browsers such as IE5.01 (JScript 5.0), there is no apply and call. Therefore, there will be some compatibility issues. Here are the fixes:
if(!Function.prototype.apply){
Function.prototype.apply = function(obj, args){
obj = obj == undefined ? window : Object(obj);//obj can be js basic type
var i = 0, ary = [], str;
if(args){
ary[i ] = "args[" i "]"; ;
try{
return eval(str);
}catch(e){
}finally{
delete obj._apply;
}
};
}
if(!Function.prototype.call){
Function.prototype.call = function(obj){
var i = 1, args = [];
for( len=arguments. length; i args[i-1] = arguments[i];
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn