Skip to content

Instantly share code, notes, and snippets.

@jdittrich
Last active August 29, 2015 14:21
Show Gist options
  • Save jdittrich/d9583c0b9a95b65b696f to your computer and use it in GitHub Desktop.
Save jdittrich/d9583c0b9a95b65b696f to your computer and use it in GitHub Desktop.
Redirect Page
<!DOCTYPE html>
<html>
<head>
<title>Untitled Document</title>
<meta charset="UTF-8">
<meta name="description" content="">
<meta name="keywords" content="">
</head>
<body>
Hey there! You going to see a page for devs… or designers… <!-- this will be visible for 1 second -->
<script type="application/javascript">
window.setTimeout(function(){/*the setTimeouit wrapper inhibits the functions for one second so that users can see the page very briefly*/
if(Math.floor(Math.random() * 100)%2 == 1){/*This is the random number generator. Math.floor(Math.random() * 100) generates a number between 0 and 100, %2 gives us the rest of a division by 2. == 1 means: if there was a rest (1) do what is in the {}; else do the stuff behind "else" */
window.location="https://news.ycombinator.com/"; /*one target address (choosen for odd numbers)*/
} else {
window.location="https://news.layervault.com/"; /*other target address (choosen for even numbers)*/
}
},1000) //1000 means 1000 millisec means 1 sec.
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment