function String.prototype.Trim()   
{   
      return this.replace(/^\\s*/g,"").replace(/\s*\$/g,"");   
}
错误行显示在这个函数上,是不是这种写法Firefox不支持?  

解决方案 »

  1.   

    这样就好了。
    String.prototype.Trim = function() {  
        return this.replace(/^\s*|\s*$/g,"");
    }alert("[" + " 123 ".Trim() + "]")function String.prototype.Trim() 写法不标准。
      

  2.   

    OK,问题解决。谢了!!
    function String.prototype.Trim()   
    {   
      return this.replace(/^\\s*/g,"").replace(/\s*\$/g,"");   
    }
    能帮我解释一下这个函数的意思吗?
      

  3.   

    去掉前后空白字符。"   abc " -> "abc"