badcrocodile
9/12/2014 - 1:02 PM

Grab URL variables

Grab URL variables

Requests = {
QueryString : function(item){
var svalue = location.search.match(new RegExp("[\?\&]" + item + "=([^\&]*)(\&?)","i"));
return svalue ? svalue[1] : svalue;
}
}

//usage
Requests.QueryString("id");

// Sourced from http://css-tricks.com/snippets/javascript/get-url-variables/