Skip to content

Instantly share code, notes, and snippets.

@zerda
Last active June 30, 2016 00:00
Show Gist options
  • Save zerda/8d1fef075aea57c5a2d945e3658934cf to your computer and use it in GitHub Desktop.
Save zerda/8d1fef075aea57c5a2d945e3658934cf to your computer and use it in GitHub Desktop.
Parse Url Param by Vanilla JavaScript
function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName
for (var i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=')
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : sParameterName[1]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment