jQuery - 在新页面中打开随机链接[关闭]

jQuery  - 在新页面中打开随机链接[关闭]

问题描述:

This code is woking after 5sec on click this open the link in a new page, but I want to do now is to at radom links, so i want to add 5 links, someone can help me to show me how i can add more links here ? thanks

    $(document).click(function() {
        setTimeout(function () {
            window.open('https://google.com', '_blank');
            window.focus();
        }, 5000);
    });

这段代码在点击5秒后就开始了,这打开了新页面中的链接,但我现在要做的是 到radom链接,所以我想添加5个链接,有人可以帮我告诉我如何在这里添加更多链接? 谢谢 p>

  $(document).click(function(){
 setTimeout(function(){
 window.open('https://google.com',  '_blank'); 
 window.focus(); 
},5000); 
}); 
  code>  pre> 
  div>

Maybe this will help you .

var textArray = ['https://www.google.com','https://www.facebook.com','https://www.yahoo.com','https://www.twitter.com'];
    var randomNumber = Math.floor(Math.random()*textArray.length);
    setTimeout(function () {
        window.open(textArray[randomNumber ], '_blank');
        window.focus();
    }, 5000);