使用到的正则表达式:

[^\?&]?参数名=[^&]+

document.location.getURLPara = function (name) {
    var reg = new RegExp("[^\?&]?" + encodeURI(name) + "=[^&]+");
    var arr = this.search.match(reg);
    if (arr != null) {
        return decodeURI(arr[0].substring(arr[0].search("=") + 1));
    }
    return "";
}

使用方法:

例如地址:http://localhost/URLParas/Test.aspx?name=mo&帅不帅=太帅了

alert(document.location.getURLPara("帅不帅"));

相关文章:

  • 2021-09-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-13
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案