<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" c>
<meta name="viewport" c>
<script src="script.js" defer></script>
<title>5秒後跳轉到新網站</title>
</head>
<body>
<main>
<center>網頁即將在 <span id="timeBox"></span> 後跳轉到新網站</center>
</main>
</body>
</html>
// 設定秒數
var count = 5;
function countDown(){
// 將秒數寫在指定元素中
document.getElementById("timeBox").innerHTML= count;
// 每次執行就減1
count -= 1;
// 當 count = 0 時跳轉頁面
if (count == 0){
location.href="http://www.adj.idv.tw";
}
// 設定每秒執行1次
setTimeout("countDown()",1000);
}
// 執行 countDown
countDown();
歡迎光臨 ADJ網路實驗室 (http://dz.adj.idv.tw/) | Powered by Discuz! 6.0.0 |