mardi 14 novembre 2017

Open multiple links, in random order, by clicking one link

I am trying to create a link that when clicked will open three tabs to three different urls - each time in random order.

So "Click me" would open example.com, google.com, facebook in three tabs, in random order.

So far I have this code, it selects a random link, but only one of them - I want to open all three at once, but in random order

<script type="text/javascript">
    var urls = [
        "http://example.com",
        'http://google.com',
        'http://facebook.com'
    ];

    function goSomewhere() {
        var url = urls[Math.floor(Math.random()*urls.length)];
        window.location = url; // redirect
    }
</script>

<a href="#" onClick="goSomewhere(); return false;">Start</a>




Aucun commentaire:

Enregistrer un commentaire