Created
January 14, 2014 22:47
-
-
Save GingerBear/8427464 to your computer and use it in GitHub Desktop.
JavaScript URL parameters parsing by Regular Expression
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
function url_param(url) { | |
var _url = url || window.location.href; | |
var array = _url.match(/\w+=\w+/g); | |
var result = {}; | |
var tmp = []; | |
for (var i = 0; i < array.length; i++) { | |
tmp = array[i].split("="); | |
result[tmp[0]] = tmp[1]; | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment