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
tmitch1968Asked:
Who is Participating?
 
RobOwner (Aidellio)Commented:
no you need to parse it yourself (window.location.search) or use one of the many functions find online.
0
 
RobOwner (Aidellio)Commented:
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
0
 
tmitch1968Author Commented:
Awesome - thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.