Thursday, April 1, 2010

Script to get query string

From the answers here (which refers to this article):

// Get the query parameter string.
// Usage: If URL is "blah.com/index.html?view=classic", then do this to get the value of "view":
// var parm = $.urlParam('view');
// See http://stackoverflow.com/questions/901115/get-querystring-with-jquery.
$.urlParam = function (name) {
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
if (!results) { return 0; }
return results[1] || 0;
};

No comments:

Post a Comment