Quantcast
Channel: w3cplus
Viewing all articles
Browse latest Browse all 1557

js通过参数名获取url查询中参数的值

$
0
0
function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location.search);
    return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, ""));
}

Viewing all articles
Browse latest Browse all 1557

Trending Articles