在IE5下的Javascript:
Array不支持push;Function不支持apply();String对象的replace方法不支持替换成一个处理函数。
使用下面的代码就可修复上述方法在IE5下无效的问题。 /*
fix-ie5.js,version1.0x3 Copyright2005,DeanEdwards
Web: ThissoftwareislicensedundertheCC-GNULGPL
Web: */
if(/MSIE5.0/.testnewfunction(){
var$$apply=function($function,$object,$arguments){ $function.apply; };
//fixString.replace if(”.replace{ //preserveString.replace
var_stringReplace=String.prototype.replace;
//createString.replaceforhandlingfunctions
var_functionReplace=function($expression,$replacement){
var$match,$newString=””,$string=this;
while($string&&($match=$expression.exec{
$newString+=$string.slice+$$apply($replacement,this,$match);
$string=$string.slice; } return$newString+$string; };
//replaceString.replace
String.prototype.replace=function($expression,$replacement){
this.replace=(typeof$replacement==”function”)?_functionReplace:_stringReplace;
returnthis.replace($expression,$replacement); }; } //fixFunction.apply
if{ varAPPLY=”apply-“+Number; $$apply=function{ varr; o[APPLY]=f;
switch{//deconstructforspeed case0:r=o[fix-ie5.js扩展在IE5下不能使用的几个方法_javascript技巧_脚本之家。APPLY]();break;
case1:r=o[APPLY];break; case2:r=o[APPLY];break;
case3:r=o[APPLY];break; case4:r=o[APPLY];break; default:
varaa=[],i=a.length-1; doaa[i]=”a[“+i+”]”;while; eval; }
deleteo[APPLY]; returnr; }; //fixICommon
ICommon.valueOf.prototype.inherit=function(){
return$$apply(arguments.callee.caller.ancestor,this,arguments); }; }
//arrayfixes ifArray.prototype.push=function(){ for(vari=0;i
fix-ie5.js扩展在IE5下不能使用的几个方法_javascript技巧_脚本之家
相关文章
- www.6766.com动态调用css文件——jquery的应用_jquery_脚本之家
- Photokina 2018:除了全幅无反,还有这些亮点 – 相机,镜头 – IT之家
- 小米手机中秋狂促0点开启:全场最高省1000元,仅此1天
- 国货当自强!我被国产手机这些技术创新惊艳到了 – OPPO Find X,华为P20 Pro,小米MIX – IT之家
- 马云:没有QQ还会有JJ,一定要创新 – Windows7之家,Win7之家
- 人人接到纽交所警告:股价连续30个交易日低于1美元 – 人人公司,人人 – IT之家
- 小米2017感恩季马上开启:官网大批产品降价! – 小米,小米感恩季 – IT之家
- www.6766.comvivo NEX真机曝光:无刘海全面屏,前置摄像头位于右下角 – vivo,vivo NEX – IT之家
- 从“山寨”到创新,日本制造业兴衰启示录 – 制造业,日本 – IT之家
- 在chrome中window.onload事件的一些问题_javascript技巧_脚本之家
- php常用数组函数实例小结_php技巧_脚本之家
- MySQL防止delete命令删除数据的两种方法