userimage

How can I get query string values in JavaScript?

Is there a way of retrieving query string values via jQuery (or without) without using any plugin"s?

If so, how? If not, is there a plugin which can do so?


Appreciate quick responce

userimage

The following Javascript will work just fine.

function getString(someString) {

    someString = someString.replace(/[[]/, "[").replace(/[]]/, "]");

    var regex = new RegExp("[?&]" + someString + "=([^&#]*)"),

        results = regex.exec(location.search);

    return results === null ? "" : decodeURIComponent(results[1].replace(/+/g, " "));

}


You can get it the following way :

var variable = getString('variable');

Answer is