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);