Possible Duplicate:
Use the get paramater of the url in javascript
How can I get query string values in JavaScript?
In Javascript, how can I get the parameters of a URL string (not the current URL)?
like:
www.domain.com/?v=123&p=hello
Can I get “v” and “p” in a JSON object?
2.5 years after the question was asked you can safely use
Array.forEach. As @ricosrealm suggests,decodeURIComponentwas used in this function.actually it’s not that simple, see the peer-review in the comments, especially:
=(@AndrewF)+(added by me)For further details, see MDN article and RFC 3986.
Maybe this should go to codereview SE, but here is safer and regexp-free code:
This function can parse even URLs like
7 years after the question was asked the functionality was standardized as URLSearchParams and 4 more years after, the access can be further simplified by Proxy as explained in this answer, however that new one can not parse the sample url above.