Skip to content

Instantly share code, notes, and snippets.

@shubham7298
Created August 29, 2018 04:58
Show Gist options
  • Save shubham7298/7e13c6ffef41399eeecdd2641f552b75 to your computer and use it in GitHub Desktop.
Save shubham7298/7e13c6ffef41399eeecdd2641f552b75 to your computer and use it in GitHub Desktop.
Retreiving Values from URL Query
function getQueryStringValue (key) {
return decodeURIComponent(window.location.search.replace(new RegExp("^(?:.*[&\\?]" + encodeURIComponent(key).replace(/[\.\+\*]/g, "\\$&") + "(?:\\=([^&]*))?)?.*$", "i"), "$1"));
}
// Would write the value of the QueryString-variable called name to the console
var quer = getQueryStringValue("a");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment