Get query string value from URL

Hi

I am after one of the query string values in the URL using ‘client side’.

I know how to do this with php, but in this case I don’t have access to the server.

http://site.com/?blah=foo&abc=some-value

<?php echo $_GET['abc']; ?>

Usage:

Result:

After googling it, and reading several posts, they all seem to be overly complicated… building arrays of key and var. The answers seem to be trying to build the all encompassing universal get all possible params.

I don’t need all possible params, I simply need the value of “abc”.

Is there a simple way of doing this in javascript?

Googling I finally found one that wasn’t trying to be all encompassing.

Does this work?:

Tried this (not working)

http://site.com/test.html?foo=bar&abc=some-value

This did not work.

I wonder of “alert” is used more to ‘write to screen’, I only need to write to html ie. the value in the form.

Any advice?

This appears to be held up as the industry standard for retrieving query string by javascript, (found several references pointing to it.) http://css-tricks.com/snippets/javascript/get-url-variables/

http://site.com/test.html?foo=bar&abc=something

// Didn't work // Didn't work

I just don’t have experience with javascript.

Any advice?

Sponsor our Newsletter | Privacy Policy | Terms of Service