Last active
August 29, 2015 14:14
-
-
Save alikrc/0708c98e1a57367b7a78 to your computer and use it in GitHub Desktop.
[javascript snippet] get query string parameter on url
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
//returns query parameters as object | |
function getQueryString() { | |
var result = {}, queryString = location.search.slice(1), | |
re = /([^&=]+)=([^&]*)/g, m; | |
while (m = re.exec(queryString)) { | |
result[decodeURIComponent(m[1])] = decodeURIComponent(m[2]); | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment