Here you can easily read and understand the JS function, which you can use to extract any variable from the URL.
All you have to do is call this function with the name of the variable you want to filter, and it will return you a value.
Hope this helps:
function getVarFromURL(varName){
var url = window.location.href;
url = url.substring(url.indexOf('?'));
var urlLowerCase = url.toLowerCase();
varName = varName.toLowerCase();
if (urlLowerCase.indexOf(varName + "=") != -1) {
var value = url.substring(urlLowerCase.indexOf(varName) + varName.length + 1);
if (value.indexOf('&') != -1) {
value = value.substring(0, value.indexOf('&'));
}
return value;
}
else {
return null;
}
}
source
share