Last active
December 14, 2015 22:49
-
-
Save varemenos/5161407 to your computer and use it in GitHub Desktop.
JavaScript - Parse url parameters
This file contains hidden or 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 params = {}; | |
var queryString = location.search.substring(1); // For # params use location.hash | |
var regex = /([^&=]+)=([^&]*)/g; | |
var m; | |
while (m = regex.exec(queryString)) { | |
params[decodeURIComponent(m[1])] = decodeURIComponent(m[2]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment