Stephen Daly - ASP.net/C# developer & technology enthusiast

Parsing a Querystring in JavaScript example

I was asked to get the value of a giving query string name through JavaScript. The following is the function I created to return the value of a specific query string.

function QueryString(name)

{

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

   param = url.split("&");  

   for (i=0;i<param.length;i++)

   {

        value = param[i].split("="); 

        if (value[0] == name)

        {

             return this.unescape(value[1]);

        }

    }

}


Posted by: Stephen
Posted on: 17/02/2008 at 7:02 PM
Tags: , , ,
Actions: E-mail | Digg it! | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Comments

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading