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 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 + = $ Str Ing. slice (0, $ match. index) + $ apply ($ replacement, this, $ match);
$ string = $ string. slice ($ match. lastindex);
}< br> 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 (. 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 =. length-1;
do Aa [I] = "A [" + I + "]"; while (I --);
eval ("r = O [apply] (" + AA + ")");
}< br> 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 This [this. length] = arguments [I];
}< br> return this. length;
};
If (! []. Pop) array. prototype. pop = function () {
var $ item = This [this. length-1];
This. length --;
return $ item;
};