How to get the Query string value through javascript

Requirement is to get the querystring value through javascript.

Here Querystring variable name is “Tag”

Add this function in the javascript block of the page and call according to the requirement.I am calling this function on page load.

Here is code:

—————————–

function querySt() {

var url = window.location.search.substring(1);

var qSColl = url.split(“&”);

for (i=0;i<qSColl.length;i++) {

qsValue = qSColl[i].split(“=”);

if (qsValue[0] == ’Tag’) {

tabValue = qsValue[1];

}

}

}

———————————

So this way you  can access any variable value from the querystring

So your job is done

Enjoy!!!

Advertisement

~ by Saurabh Mittal on September 19, 2009.

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 )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.