HOWTO: Parse URLs using Javascript to extract GET variables and more

Most server side languages have inbuilt capabillity of reading GET variables passed via the URL.

But in two (or more) cases, we may need to read these variabes on the client side using javascript. This might be when:

  • You need to find out what the server did/will do on recipt of a particular URL (usually the one on which you currently are)
  • You are building a dynamic AJAX based website, and you are making dynamically loaded content linkable using # in the URL (example: http://jrharshath.com/blog#Article?articleid=12345).

I am currently building an AJAX based application on jswaf and it faces second problem, so I wrote a script for this express purpose: to parse URL like strings into BaseURL and key-value paired parameters.

The code is located here, and a demo is located here.

The code is free to borrow. Just provide credits if you do, and drop me a line if you like it, or would like to learn how to use it.

Advertisements

One thought on “HOWTO: Parse URLs using Javascript to extract GET variables and more

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s