Skip to content

Instantly share code, notes, and snippets.

@brendanc
Last active January 17, 2018 14:07
Show Gist options
  • Select an option

  • Save brendanc/19240f1c7ae44782e5024365084c4f4a to your computer and use it in GitHub Desktop.

Select an option

Save brendanc/19240f1c7ae44782e5024365084c4f4a to your computer and use it in GitHub Desktop.
redirect to random image
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function redirect() {
var random = Math.floor(Math.random() * Math.floor(5)) + 1; // random number between 1 and 5
var number = random*100; // just make this bigger for this example only so placeholder image is reasonable
var image = "http://via.placeholder.com/" + number + ".png";
window.location.replace(image);
}
window.onload = redirect;
</script>
</head>
<!-- in case javascript is disabled or something else goes wrong, just redirect to this image -->
<meta http-equiv="refresh" content="2;url=http://via.placeholder.com/300.png">
<body></body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment