<script language=Javascript>  //自己动手为string添加Trim
function String.prototype.Trim() {return this.replace(/(^\s*)|(\s*$)/g,"");}
function String.prototype.Ltrim(){return this.replace(/(^\s*)/g, "");}
function String.prototype.Rtrim(){return this.replace(/(\s*$)/g, "");}
var str = "  hrong   ";
alert(str.Trim());
alert(str.Ltrim());
alert(str.Rtrim());
</script>