Last active
October 18, 2016 19:06
-
-
Save tomkuijsten/8d52953e216d4006a1328bfb56ffa415 to your computer and use it in GitHub Desktop.
Html which redirects to another url based on query param
This file contains 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
<html> | |
<head> | |
<script type="text/javascript"> | |
// stolen from: http://stackoverflow.com/questions/11823784/redirection-to-a-specific-web-page-based-on-url-parameter-using-javascript | |
// http://minwinpc/RedirectUsingQueryParameter.html?selection=a | |
function getQueryStringArray(){ | |
var assoc=[]; | |
var items = window.location.search.substring(1).split('&'); | |
for(var j = 0; j < items.length; j++) { | |
var a = items[j].split('='); assoc[a[0]] = a[1]; | |
} | |
return assoc; | |
} | |
var qs = getQueryStringArray(); | |
var url = ''; | |
if (qs.selection !== 'undefined' && qs.selection) { | |
switch (qs.selection) { | |
case 'a': | |
url = '/imagebutton/a.html'; | |
break; | |
case 'b': | |
url = '/imagebutton/b.html'; | |
break; | |
} | |
window.location.href = url; //reroute | |
} | |
</script> | |
</head> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment