console
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>随机顺序循环跳转页面示例</title>
<script>
var links = [
'https://example.com/link1',
'https://example.com/link2',
'https://example.com/link3',
'https://example.com/link4',
];
var visitedIndices = [];
function openRandomLink() {
if (visitedIndices.length === links.length) {
visitedIndices = [];
}
var randomIndex;
do {
randomIndex = Math.floor(Math.random() * links.length);
} while (visitedIndices.includes(randomIndex));
window.open(links[randomIndex], '_blank');
visitedIndices.push(randomIndex);
}
</script>
</head>
<body>
<h1>随机顺序循环跳转页面示例</h1>
<button onclick="openRandomLink()">打开随机链接</button>
</body>
</html>