ProAnswers.org

Get query string values in JavaScript

Get query string values in JavaScript

1 Like

You don’t need jQuery for that purpose you can use the pure JavaScript:

function getParameterByName(name)
{
name = name.replace(/[[]/, β€œ\[”).replace(/[]]/, β€œ\]”);
var regexS = β€œ[\?&]” + name + β€œ=([^]*)”;
var regex = new RegExp(regexS);
var results = regex.exec(window.location.href);
if(results == null)
return β€œβ€;
else
return decodeURIComponent(results[1].replace(/+/g, " "));
}