Skip to content

Instantly share code, notes, and snippets.

@EnotionZ
Last active December 22, 2016 14:41
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 EnotionZ/7537030 to your computer and use it in GitHub Desktop.
Save EnotionZ/7537030 to your computer and use it in GitHub Desktop.
Get URL Parameter
var getURLParameter = function(name) {
var valStr = decodeURIComponent( (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[0,null])[1]);
return valStr === 'null' ? null : valStr;
};
// url param map
var urlParams = location.search.substr(1).split('&').reduce(function(map, item) {
item = item.split('=');
map[item[0]] = item[1];
return map;
}, {});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment