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呢,下面这张图片可以告诉你哦!!!

escape ,unescape 不再使用了,使用encodeURIComponent吧

 上图可见,encodeURIComponent可以转译的更多,包括特殊字符。

相关文章:

  • 2021-09-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-13
  • 2021-12-14
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-18
  • 2021-07-04
  • 2021-08-05
  • 2022-12-23
  • 2021-11-13
  • 2022-12-23
相关资源
相似解决方案