Last active
December 22, 2016 14:41
-
-
Save EnotionZ/7537030 to your computer and use it in GitHub Desktop.
Get URL Parameter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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