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

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");

 

posted @ 2014-11-21 11:44  奇风★逍遥  阅读(790)  评论(0编辑  收藏  举报