Created
November 18, 2016 16:06
-
-
Save greggnakamura/d95ebbc191b7bacb7174afee8a988ebf to your computer and use it in GitHub Desktop.
Javascript: Get query string param values
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
| // http://stackoverflow.com/questions/19491336/get-url-parameter-jquery-or-how-to-get-query-string-values-in-js | |
| var getUrlParameter = function getUrlParameter(sParam) { | |
| var sPageURL = decodeURIComponent(window.location.search.substring(1)), | |
| sURLVariables = sPageURL.split('&'), | |
| sParameterName, | |
| i; | |
| for (i = 0; i < sURLVariables.length; i++) { | |
| sParameterName = sURLVariables[i].split('='); | |
| if (sParameterName[0] === sParam) { | |
| return sParameterName[1] === undefined ? true : sParameterName[1]; | |
| } | |
| } | |
| }; | |
| var video = getUrlParameter('video'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment