
 代码如下: 
/** 
* 替换字符串中所有 
* @param obj 原字符串 
* @param str1 替换规则 
* @param str2 替换成什么 
* @return 替换后的字符串 
*/ 
function replaceAll(obj,str1,str2){ 
var result = obj.replace(eval("/"+str1+"/gi"),str2); 
return result; 
}  
例如: 
 代码如下:    
 New Document       function replaceAll(obj,str1,str2){ 
var result = obj.replace(eval("/"+str1+"/gi"),str2); 
return result; 
} 
alert(replaceAll("111,222,333",",","|")); 
 script>