簡單明了代碼
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>跳轉提示頁面</title>
<script type="text/javascript">
? // 倒計時跳轉
? function countdown() {
? ? var seconds = 5; // 跳轉倒計時秒數
? ? var countdownElement = document.getElementById('countdown');
? ? var countdownInterval = setInterval(function() {
? ? ? seconds--;
? ? ? countdownElement.innerText = seconds;
? ? ? if (seconds <= 0) {
? ? ? ? clearInterval(countdownInterval);
? ? ? ? redirectToNewPage();
? ? ? }
? ? }, 1000);
? }
? // 跳轉到新頁面
? function redirectToNewPage() {
? ? window.location.href = "http://www.xianlaiwan.cn/";
? }
? // 返回前一個頁面
? function goBack() {
? ? window.history.back();
? }
</script>
</head>
<body onload="countdown()">
? <h1>跳轉提示頁面</h1>
? <p>將在 <span id="countdown">5</span> 秒后自動跳轉到新的地址。</p>
? <button onclick="goBack()">返回</button>
</body>
</html>