Skip to content

Instantly share code, notes, and snippets.

@igorshirinkin
Created April 21, 2021 10:52
Show Gist options
  • Save igorshirinkin/2fd96cc07c85e9f6c41730558010b748 to your computer and use it in GitHub Desktop.
Save igorshirinkin/2fd96cc07c85e9f6c41730558010b748 to your computer and use it in GitHub Desktop.
Get GET parameter from URL
var params = window.location.search.replace('?','').split('&').reduce(
function(param,delim) {
var split = delim.split('=');
param[decodeURIComponent(split[0])] = decodeURIComponent(split[1]);
return param;
},{}
);
console.log(params['data']); // 'data' - name of the required GET parameter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment