dimanche 2 septembre 2018

Randomly redirect to url BUT 1 number changes (via Javascript)

So, I use this code

<script type="text/javascript">

var urls = new Array();
urls[0] = "/truth";
urls[1] = "/truth1";
urls[2] = "truth2";

var random = Math.floor(Math.random()*urls.length);

window.location = urls[random];

</script>

and I use "/truth1" "/truth2" "dare1" etc

Is it at all possible to have javascript automatically put a random number at the end of the URL between what I set it to?

It might be handy to know:
-The code above will be used on truthordare0.weebly.com/truth
(which will redirect to /truth1, /truth2, etc

Thank you very much!!




Aucun commentaire:

Enregistrer un commentaire