js a page to get the parameters passed by the url of another page

js  a page gets the parameters passed by the url of another page

For example: <a v-bind:href="'addressEdit.html?addressid='+list.addressId"> Get list.addressId on the addressEdit.html page
 
 
method one:  
function getQueryString(name) {
    var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
    var r = window.location.search.substr(1).match(reg);
    if (r != null) {
        return unescape(r[2]);
    }
    return null;
}
// call like this:
var id = GetQueryString("addressid");
alert(id);
Method Two:
 
 
 
 
function GetRequest() {
    var url = location.search; //Get the string after the "?" character in the url
    var theRequest = new Object();
    if (url.indexOf("?") != -1) {
        var str = url.substr(1);
        strs = str.split("&");
        for(var i = 0; i < strs.length; i ++) {
            theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
        }
    }
    return theRequest;
}
var Request = new Object();
Request = GetRequest();
// var parameter 1, parameter 2, parameter 3, parameter N;
// parameter1 = Request['parameter1'];






Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325607625&siteId=291194637