About Me

My photo
a Dynamic and Energetic guy.....
Showing posts with label query string. Show all posts
Showing posts with label query string. Show all posts

Wednesday, March 24, 2010

Get query string parameters using a Java Script

function getQuerystring(key, default_) {
if (default_ == null) default_ = "";
key = key.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regex = new RegExp("[\\?&]" + key + "=([^&#]*)");
var qs = regex.exec(window.location.href);
if (qs == null)
return default_;
else
return qs[1];
}

//Call the function
var CategoryID = getQuerystring('CategoryIDs');

My Masters