这些都是从网上搜集的,解决了Ie8的报错问题
//这个是解决ie8 trim的方法
Function.prototype.method = function (name, func) {
this.prototype[name] = func;
return this;
};
if (!String.prototype.trim) { //判断下浏览器是否自带有trim()方法
String.method('trim', function () {
return this.replace(/^\s+|\s+$/g, '');
});
String.method('ltrim', function () {
return this.replace(/^\s+/g, '');
});
String.method('rtrim', function () {
return this.replace(/\s+$/g, '');
});
}
//解决ie8:对象不支持“keys”属性或方法
if (!Object.keys) {
Object.keys = (function () {
var hasOwnProperty = Object.prototype.hasOwnProperty,
hasDontEnumBug = !({toString: null}).propertyIsEnumerable('toString'),
dontEnums = [
'toString',
'toLocaleString',
'valueOf',
'hasOwnProperty',
'isPrototypeOf',