Get Querystring with JavaScript - Parse/Get QueryString with Client-Side JavaScript

Updated 1 day, 9 hours ago

Source: http://www.bloggingdeveloper.com/

Nearly all server-side programming languages have built-in functions to retrieve querystring values of a URL. In web browsers you can access the querystring with client-side JavaScript, but there is no standard way to parse out the name/value pairs. So here is a function to return a parameter you specify. The following javascript code snippet facilitates Javascript's built in regular expressions to retrieve value of the key. Optionally, you can specify a default value to return when key does not ...

  • 232 comments on this story
PRO

50% positive

Showing 8 relevant reactions out of 232.

Yea nice Work !

2 months, 3 weeks ago by cash loans on Unknown

Social comments and analytics for this post

This post was mentioned on Twitter by bloggingdev: Get Querystring with JavaScript - Parse/Get QueryString with Client-Side JavaScript - http://bit.ly/HdUdO

4 months, 4 weeks ago by uberVU - social comments on Unknown

Exactly as what I am looking! This is very helpful for my new project. More articles like this please.. Will bookmark your blog.

5 months, 2 weeks ago by wow power leveling reviews on Unknown

Thanks for information.

1 year, 1 month ago by spyhidden on Unknown

<script type="text/javascript">

setInterval("doSomething()", 5000);

function doSomething()

{

// do something

}

</script> yo can use it.

1 year, 2 months ago by Lida on Unknown

This function does wok well

function getQuerystring2(key, default_)

{

if (default_==null)

{

default_="";

}

var search = unescape(location.search);

if (search == "")

{

return default_;

}

search = search.substr(1);

var params = search.split("&");

... See all content

1 year, 2 months ago by wenming wang on Unknown

FIrst, I'am confused by this line:

key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");

when i understand it , i find there is a bug.

if the key contains chars "(" , ")", the regex is wrong, finally cause

a bug.

1 year, 2 months ago by wenming wang on Unknown

Cheers matey... Just what I was looking for, and used it perfectly on our new site! Thanks

1 year, 3 months ago by ChairNut on Unknown

© uberVU Ltd. 2010

Terms of use
FEEDBACK