<html> <body> <script type="text/javascript"> var str="http://dfdf/html?df=undefined&a=undefined&c=undefined"; // 只會替換第一個 document.write(str.replace('undefined', '')); // /字符/g 表明替換全部匹配的字符串 document.write(str.replace(/undefined/g, '')); document.write(str.replace(new RegExp('undefined','g'), '')); </script> </body> </html>