alert("abacacf".replace('a','9'));
alert("abacacf".replace(/a/g,'9'));
第一个运行的结果 9bacaf 这个只是替换了第一个
第二个运行的结果 9b9c9f 这个能实现js的全部替换功能
其实第二个的意思就是用正则表达式实现全局的替换 g 代表 gobal
<script type="text/javascript"><!-- google_ad_client = "pub-1985112462197986"; /* 728x90, 创建于 09-5-7 */ google_ad_slot = "1888057268"; google_ad_width = 728; google_ad_height = 90; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>文章来源: http://www.cnblogs.com/wangdetian168/archive/2008/10/24/js-quanbutihuan.html