今天在部署网站时,发现js trim方法 出错,
我的电脑是win7 IE10 没发现任何问题,因此定位为IE兼容性问题。
百度一下,果然,IE10中使用了新的JS版本(含有TRIM方法),而IE旧版本(9以前的)中的JS版本则没有此方法。
在给string添加一方法即可。
-
String.prototype.trim = function () {
-
return this .replace(/^\s\s*/, '' ).replace(/\s\s*$/, '' );
-
}
原文地址:
阅读(274) | 评论(0) | 转发(0) |