This example describes the method for JavaScript query string parameters. Share to everyone for your reference. The implementation methods are as follows:
Copy Code code as follows:
/* Parse query string Returns an object that contains all parameters * *
function Getquerystringargs () {
Gets the query string and removes the question mark at the beginning
var qs = (Location.search.length > 0 location.search.substring (1): ");
The object that holds the data
args = {};
Get each item
var items = qs.length? Qs.split (' & '): [],
item = NULL,
name = NULL,
Used in the For loop
i = 0, len = items.length;
Add each item individually to the Args object
for (i = 0; i < len; i++) {
item = items[i].split (' = ');
Name = decodeURIComponent (item[0]);
Value = decodeURIComponent (item[1]);
if (name.length) {
Args[name] = value;
}
}
return args;
}
This makes it easy to get the corresponding parameter values in the URL.
I hope this article will help you with your JavaScript programming.