parse url and get parameters using JS
Using regex:
function getUrlParameters(url) {
var parameters = {};
url.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (m, key, value) {
parameters[key] = value;
});
return parameters;
}
alert(getUrlParameters("k=10&i=7"));
Written by Alex Navasardyan
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Javascript
Authors
Related Tags
#javascript
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#