Is it possible to transfer a new window to a random link in JavaScript? To open the window randomly
Url = new Array( "1. Site link" "2. Site link", "3.Site Link");
num = Math.floor(Math.random()*Url.length);
self.location.href= Url[num];
In this state, the url[num] does not open with window.open.It appears as a file location instead of a site link...
Or is there a way to put up a random link in a new window?
random javascript
If you do it as below, it will be normal, but in what part is it not possible?
If it appears as a file instead of a site link, doesn't the site link start with file://?
var sites = ["https://hashcode.co.kr", "https://programmers.co.kr", "https://www.google.com"];
var index = Math.floor((Math.random() * sites.length));
window.open(sites[index], '_blank'); // New tab
window.open(sites[index], '_blank', 'height=+h,width=+w'); // New Window
© 2024 OneMinuteCode. All rights reserved.