How To Get Url Parameters Using Javascript

Here, I am going to share Javascript code to get the URL querystring parameter values.

Let me take a sample URL and try to get the parameter values in it.

Here is the function to create the Javascript object with parameter names and values.

In the above code, “” is to get the query string, “replace” function and regular expression is to parse and save the parameters in the object.

Get the variables by calling above function:

Sometimes you might need to access the hash variables in the URL, below is the code for that:

Below is the code to set the hash variable for existing URL:


  1. By janamora


  2. Reply

  3. Reply

  4. By nedved


Leave a Reply

Your email address will not be published. Required fields are marked *