ie8兼容性(不支持trim 、readonly光标、乱码encodeURI())

IE8下String的Trim()方法失效的解决方案

1、用jquery的trim()方法,$.trim(str)就可以了。

2、String扩展:

第一种
String.prototype.trim = function ()  
{  
    return this.replace(/(^s*)|(s*$)/g, "");  
}  
第二种
String.prototype.ltrim = function ()  
{  
    return this.replace(/(^s*)/g, "");  
} 
第三种 
String.prototype.rtrim = function ()  
{  
    return this.replace(/(s*$)/g, "");  
}  

解决Html IE8 readonly的 textbox 中还有 光标

第一种方法:<inputtype="text" readonly="readonly"  unselectable='on'/>

第二种方法:<inputtype="text" readonly="readonly"  onfocus="this.blur()"/>

 解决乱码现象encodeURI()

原文地址:https://www.cnblogs.com/zsy0712/p/5753532.html