Last active
August 29, 2015 14:07
-
-
Save dangvanthanh/ed5ee3fa936a6f947bc9 to your computer and use it in GitHub Desktop.
Get URL Parameters Using JavaScript
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
| /** | |
| * Get URL Parameters Using JavaScript | |
| */ | |
| function getQueryParameters(qs) { | |
| qs = qs.replace(/[\[]/, '\\\[').replace(/[\]]/, '\\\]'); | |
| var regexPattern = '[\\?&]' + qs + '=([^&#]*)'; | |
| var regex = new RegExp(regexPattern); | |
| var location = window.location.href; | |
| var results = regex.exec(location); | |
| return results == null ? null ? results[1]; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment