Here is a easy to read and understand JS function that you can use to retrieve any variable from url.
All you need to do is call this function with name of the variable that you want to filter and it will return the value back to you.
Hope it helps:
All you need to do is call this function with name of the variable that you want to filter and it will return the value back to you.
Hope it helps:
function getURLParameter(name) {
return decodeURI(
(RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]
);
}
var paramValue = getURLParameter('paramName');
//alert(paramValue);
return decodeURI(
(RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]
);
}
var paramValue = getURLParameter('paramName');
//alert(paramValue);
NOTE:
- Replace 'paramName' with parameter for which you are looking to get value.
- Variable 'paramValue' stores the parameter value.
No comments: