Translator
Categories
Archives

Get QueryString Values in JavaScript

I have had several people ask me how to get URL QueryString values in JavaScript, so I created a function that will take a string, find the matching QueryString key, and return the value associated with that key. Enjoy!

NOTE: You may have to remove and re-type the “s from the code below if you copy it from this page. Some of them don’t come through correctly when you paste into your dev application.

Let's pretend the URL of this page is http://www.noobflash.com/foo/index.html?noob=someValue. The code above will find the first QueryString instance of "noob" in the URL and return the "someValue" portion to be used in your code. You would simply type queryStringValue("stringToFind") whenever you would like to get new QueryString data.

2 Responses to “Get QueryString Values in JavaScript”

Leave a Reply