I have a function that opens a number of links in new tabs when a button is clicked. Function works by looping pop() through an array holding links, with button.innerText being used to access the proper array. While testing this, it worked. it was uploaded to github, published, and is still functional.
That same function, unchanged, does not work locally. Relevant code is below. Website is live @ http://smithfanclub.info.s3-website.us-east-2.amazonaws.com/
I am also interested to know if my idea is possible. The return from the pop() is a string, and a string can't access an array. Is there a succinct way to bypass this or is a string unconquerable in this scenario.
HTML
<li><button class="generateNews" onclick="newsFunc(this)"> Mass </button></li>
<li><button class="generateNews" onclick="newsFunc(this)"> Regional </button></li>
<li><button class="generateNews" onclick="newsFunc(this)"> National </button></li>
<li><button class="generateNews" onclick="newsFunc(this)"> National2 </button></li>
<li><button class="generateNews" onclick="newsFunc(this)"> Networks </button></li>
</ul>
Function
function newsFunc(button) {
let text = button.innerText;
let National = ["https://www.msnbc.com/", "https://www.nbcnews.com/", "https://www.usnews.com/"];
let National2 = ["https://thehill.com/", "https://www.politico.com/"]
let Networks = ["https://www.wcvb.com/", "https://www.wgbh.org/", "https://whdh.com/news/local/"]
var interval = setInterval(function() {
let url = text.pop();
if (url) {
window.open(url);
} else {
clearInterval(interval);
}
}, 500);
}