JS 获取 路径参数 传入 参数名 截取 & 和 # 之前 字符

2023-04-25,,

function getQueryStringByName(name) {
var result = location.search.match(new RegExp("[\?\&]" + name + "=([^\&]+)", "i"));
if (result == null || result.length < 1) {
return "";
}
return result[1];
}

例如:

Response.Redirect("/Questions/Activities/ReportGeneration.aspx?Id=" + Id + "&scale_bId=" + scale_bId);

JS里面直接可以取出路径后面滴参数   getQueryStringByName("Id");

JS 获取 路径参数 传入 参数名 截取 & 和 # 之前 字符的相关教程结束。

《JS 获取 路径参数 传入 参数名 截取 & 和 # 之前 字符.doc》

下载本文的Word格式文档,以方便收藏与打印。