if(!String.prototype.trim){ String.prototype.trim=function(){ return this.replace(/^\s+|\s$/g,""); } }
例:var str=" Hello Javascript ";
str=str.trim();
document.write(str);