自动跳转
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>自动跳转</title> <style> p { text-align: center; color: black; font-family: 宋体; } p span { color: red; font-family: 宋体; } </style> </head> <body> <p> <span id="time">5</span>秒之后,自动跳转到python3文档 </p> <p> <a href="https://docs.python.org/zh-cn/3/" id="jumping">点击立刻跳转</a> </p> <script> var sec = 5; time = document.getElementById("time"); var m = setInterval(countdown, 1000) function countdown() { if (time.innerHTML == 0) { clearInterval(m); location.href = 'https://docs.python.org/zh-cn/3/'; } else { sec -= 1; time.innerHTML = sec; } } </script> </body> </html>