escape ,unescape 不再使用了,使用encodeURIComponent吧
getUrlParam = function (name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) return decodeURIComponent(r[2]); return null;
}
var nickName = $.getUrlParam("nickName");
var encodedKey = encodeURIComponent(nickName);
document.location.href = "/activity/join?nickName=" + nickName
为什么使用encodeURIComponent呢,下面这张图片可以告诉你哦!!!
上图可见,encodeURIComponent可以转译的更多,包括特殊字符。