// 跳转url, 跳转过的不再跳转,从第一个继续跳转,输入参数为链接数组
const urlstr = 'url1,url2,url3,url4';
function jumpUrl() {
const urls = urlstr.split(',');
let visited = localStorage.getItem('urlset') ? JSON.parse(localStorage.getItem('urlset')) : []
for (let i = 0; i < urls.length - 1; i++) {
const url = urls[i];
if (urls[i] && !visited.find(item => item ===(urls[i]))) {
visited.push(url);
localStorage.setItem('urlset', JSON.stringify(visited));
// window.location.href = url;
alert('跳转到'+url)
return;
}
}
// 如果都已经被访问过了,清掉重来
visited = [];
localStorage.setItem('urlset', JSON.stringify(visited));
// window.location.href = urls[urls.length - 1];
const url = urls[urls.length - 1];
alert('跳转到'+url)
return false;
}
jumpUrl()
console