A simple function to easily retrieve GET parameters by name.
Example:
for the URL: https://www.example.com/?prodID=1234
var prodId = getParameterByName('prodId');
Sets the javascript variable "prodID" to "1234" as defined on the GET string.
/* * function getParameterByName(name) * returns value defined in URL parameter */ function getParameterByName(name) { name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); var regex = new RegExp("[\\?&]" + name + "=([^]*)"), results = regex.exec(location.search); return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); }
Subscribe To Our Newsletter
Join our mailing list to receive the latest news and updates from our team.
You have Successfully Subscribed!