Skip to content

Instantly share code, notes, and snippets.

@rxnlabs
Last active December 25, 2015 05:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rxnlabs/6923061 to your computer and use it in GitHub Desktop.
Save rxnlabs/6923061 to your computer and use it in GitHub Desktop.
Javascript - Read URL parameters from URL string
//source http://papermashup.com/read-url-get-variables-withjavascript/
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;
}
var first = getUrlVars()["get_variable_here"];
var second = getUrlVars()["get_variable_here"];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment