String.prototype.replaceAll = function (targetStr, newStr) { var sourceStr = this.valueOf(); while (sourceStr.indexOf(targetStr) !== -1) { sourceStr = sourceStr.replace(targetStr, newStr); } return sourceStr;};