I want to create a pop window and open a list of URLs in the browser. So when the first page loads in the pop up window, Wait for the page to load then open the next page... Go through the list of urls. To wait for the page to load, I use setTimeout. But I can't seem to make my code work, because of the for loop and the setTimeout. The window skips directlt to the last url in the list. Is there any other way I can make it work? Thank you,
Here's my code:
// exammple of list urls
var my_list = ['https://www.youtube.com/watch?v=77kOn5NZBHw',
'https://www.youtube.com/watch?v=1IRo21UhvZg',
'https://www.youtube.com/watch?v=yRJxz0NicgI'
]
// open a new pop up window
var response = window.open(my_list[0], 'new', true);
for (let i = 0; i < my_list.length; i++) {
setTimeout(function() {
console.log(response.location.href);
response.location = my_list[i];
}, 3000)
};