日期:2014-05-16  浏览次数:20308 次

js实现replaceAll()功能,如“this is a test” 把所有的is替换成abc
<script language="javascript">
function replaceAll(){
var a="is";
var b="abc";
var c="this is a is testis";
var index;
var mm;
do{
mm=c.replace(a,b);
index=mm.indexOf(a);
c=mm;
}while(index!=-1);
alert(mm);
}
</script>
<body onload="replaceAll()">