a页面通过url传id到b页面,b页面获取到的是经过url转码的,为了取到汉字,需要将之转为汉字
这是在b页面写的。
//获取传过来的id值
var url = window.location.search;
console.log("转码前",url)
function GetUrlParam(userType) {
var reg = new RegExp("(^|&)" + userType + "=([^&]*)(&|$)");
var r = encodeURI(window.location.search).substr(1).match(reg);
if (r != null) return unescape(r[2]); return null;
}
var userType = decodeURI(GetUrlParam("id"));
console.log("转码后",userType)
url传文字转码
最新推荐文章于 2019-10-12 10:35:53 发布