Ad Code

Open specific link in new tab on page load jquery

 <script>
$(document).ready(function(){

    window.setTimeout(function(){
        var link = document.getElementById("link").href;
        var newTab = window.open(link, '_blank');
    }, 5000);
});
<
/script>
 

Here's a simple way to do it.

<script>
    var sites = [
        'http://www.google.com',
        'http://www.stackoverflow.com',
        'http://www.example.com',
        'http://www.youtube.com'
    ];

    function randomSite() {
        var i = parseInt(Math.random() * sites.length);
        location.href = sites[i];
    }
</script>
<a href="#" onclick="randomSite();">Random</a>

Post a Comment

0 Comments