Last active
December 31, 2015 20:09
-
-
Save mkokes/cfd6626555c899dbb55a to your computer and use it in GitHub Desktop.
Get the URL parameters from a URL using jQuery
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
| //Parse parameters in URL | |
| function getURLParameter(sParam) | |
| { | |
| var sPageURL = window.location.search.substring(1); | |
| var sURLVariables = sPageURL.split('&'); | |
| for (var i = 0; i < sURLVariables.length; i++) | |
| { | |
| var sParameterName = sURLVariables[i].split('='); | |
| if (sParameterName[0] == sParam) | |
| { | |
| return sParameterName[1]; | |
| } | |
| } | |
| } | |
| //Usage Examples | |
| var tech = getURLParameter('technology'); | |
| var blog = getURLParameter('blog'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment