<body>
<script>
var arr = new Array(
"http://baidu.com/web1/",
"http://baidu.com/web2/",
"http://baidu.com/web3/",
"http://baidu.com/web4/",
);
window.location.href = arr[Math.floor(Math.random() * arr.length)];
</script>
</body>
別人打開首頁自動跳轉到指定頁,現在是無規律隨機跳轉,想改為按排列順序,謝謝。
uj5u.com熱心網友回復:
var arr = new Array(
"http://baidu.com/web1/",
"http://baidu.com/web2/",
"http://baidu.com/web3/",
"http://baidu.com/web4/"
);
var index = parseInt(localStorage.myIndex || "0", 10);
localStorage.myIndex = (index+1)%arr.length;
window.location.href = arr[index];
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/129031.html
標籤:HTML5
