JS代码URL传中文参数乱码
程序员文章站
2022-07-12 18:07:14
...
1.传值
window.location.href ='html/search.html?search='+escape(val);
加上escape()
2.接收
unescape(getUrlParms("productName"));
3.获取传值
function getUrlParms(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null)
return unescape(r[2]);
return null;
}