Fix-ie5.js extensions in IE5 cannot use several methods in IE5 Javascript:
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 (){
// 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;
};
};
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.