Skip to content

Instantly share code, notes, and snippets.

@ijxsid
Last active August 29, 2016 10:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ijxsid/2a197ff0ae32faa014968b16d9070b5d to your computer and use it in GitHub Desktop.
Save ijxsid/2a197ff0ae32faa014968b16d9070b5d to your computer and use it in GitHub Desktop.
Redirection via Javascript (Add this to any HTML page, and it will direct to a given 'next' url param)
<script type="text/javascript">
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];
}
}
};
if getUrlParameter('next') {
window.location = getUrlParameter('next') + window.location.hash;
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment