Link to home
Create AccountLog in
Avatar of tmitch1968
tmitch1968

asked on

In javascript, what is the easiest way to get a parameter from the url?

Hello,

Isn't there a simple way to get a parameter from the url within javascript?  For example, is there a way to get the value of param1 from http://somesite.com/somepage.php?param1=asdf

Thanks in advance
ASKER CERTIFIED SOLUTION
Avatar of Rob
Rob
Flag of Australia image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
http://www.w3schools.com/jsref/prop_loc_search.asp shows how to retrieve the querystring.

you could use this plugin https://github.sindresorhus/query-string

they all essentially use regular expressions to extract the key value pairs into an object
Avatar of tmitch1968
tmitch1968

ASKER

Awesome - thanks!