解决trim()方法在IE6版本的不兼容问题
//首先,判断当前浏览器的String类型的原型对象是否支持trim方法
if(!("trim" in String.prototype)){//如果不包含
//只有放在原型对象中的方法才能被所有子对象调用
document.write("自己写的方法!");
String.prototype.trim=function(){
return this.replace(/^\s+|\s+$/g,"");
}
}
var str="\t hello world \t";
document.write(str.trim());