Javascript in IE5:
Array does not support push (), pop (); Function does not support apply (); The String object's replace method does not support replacement into a processing Function.
Use the following code to fix the problem that the above method is invalid in ie5.
/*
Fix-ie5.js, version 1.0 (pre-release) () x3
Copyright 2005, Dean Edwards
Web: http://dean.edwards.name/
This software is licensed under the CC-GNU LGPL
Web: http://creativecommons.org/licenses/LGPL/2.1/
*/
If (/MSIE 5.0/. test (navigator. userAgent) new function (){
Var $ apply = function ($ function, $ object, $ arguments ){
$ Function. apply ($ object, $ arguments );
};
// Fix String. replace
If (''. replace (/^/, String )){
// Preserve String. replace
Var _ stringReplace = String. prototype. replace;
// Create String. replace for handling functions
Var _ functionReplace = function ($ expression, $ replacement ){
Var $ match, $ newString = "", $ string = this;
While ($ string & ($ match = extends expression.exe c ($ string ))){
$ NewString + = $ string. slice (0, $ match. index) + $ apply ($ replacement, this, $ match );
$ String = $ string. slice ($ match. lastIndex );
}
Return $ newString + $ string;
};
// Replace String. replace
String. prototype. replace = function ($ expression, $ replacement ){
This. replace = (typeof $ replacement = "function ")? _ FunctionReplace: _ stringReplace;
Return this. replace ($ expression, $ replacement );
};
}
// Fix Function. apply
If (! Function. apply ){
Var APPLY = "apply-" + Number (new Date );
$ Apply = function (f, o, ){
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 );
};
}
// Array fixes
If (! []. Push) Array. prototype. push = function (){
For (var I = 0; I <arguments. length; I ++ ){
This [this. length] = arguments [I];
}
Return this. length;
};
If (! []. Pop) Array. prototype. pop = function (){
Var $ item = this [this. length-1];
This. length --;
Return $ item;
};
};