2、ode字符无效。php编码方法:urlencode,rawurlencode,htmlentities。urlencode和rawurlencode唯一的区别是对空格的编码方式不同,rawurlencode遵循RFC1738编码将空格转换为%20。如何用js实现php的urlencode功能,网上流传着一段js和vbscript混写的代码,通用性不好,另找到国外一高人写的,经测试与urlencode相同。代码 1 function URLEncode (clearString) { 2 var output = ''; 3 var x = 0; 4
3、 clearString = clearString.toString(); 5 var regex = /(^[a-zA-Z0-9-_.]*)/; 6 while (x < clearString.length) { 7 var match = regex.exec(clearString.substr(x)); 8 if (match != null && match.length > 1 && match[1] != '') { 9 output += match[1];10 x += matc