Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Html which redirects to another url based on query param
<script type="text/javascript">
// stolen from:
// http://minwinpc/RedirectUsingQueryParameter.html?selection=a
function getQueryStringArray(){
var assoc=[];
var items ='&');
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';
case 'b':
url = '/imagebutton/b.html';
window.location.href = url; //reroute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment