Skip to content

Instantly share code, notes, and snippets.

@ennjoy
Last active August 5, 2021 14:23
Show Gist options
  • Save ennjoy/0afcfb1b5b3afb38bc903681608077ab to your computer and use it in GitHub Desktop.
Save ennjoy/0afcfb1b5b3afb38bc903681608077ab to your computer and use it in GitHub Desktop.
function getUrlParameter(sParam) {
var sPageURL = 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 typeof sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1])
}
}
return false
}
if (getUrlParameter('ref')) {
$.cookie('referer', getUrlParameter('ref'), { expires: 7 })
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment