Home >Web Front-end >JS Tutorial >Use js to set url parameters_javascript skills

Use js to set url parameters_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:29:44857browse
// Get the parameter array of the address bar
function getUrlParams() {
var search = window.location.search;
// Write the data dictionary
var tmparray = search.substr(1, search.length).split("&");
var paramsArray = new Array;
if (tmparray != null) {
for (var i = 0; i var reg = /[=|^==]/; // Use = to split, but not ==
var set1 = tmparray[i ].replace(reg, '&');
        var tmpStr2 = set1.split('&');
        var array = new Array; ;
paramsArray.push(array);
}
}
// Return the parameter array
return paramsArray;
}

// Get the parameter value according to the parameter name
function getParamValue(name) {
var paramsArray = getUrlParams();
if (paramsArray != null) {
for (var i = 0; i             for (var j in paramsArray[i])                                                      > } }
}
}
return null;
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn