赞
踩
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>自动跳转</title> <style type="text/css"> p{ text-align: center; } span{ color: red; } </style> </head> <body> <p> <span id="time"> 5 </span> 秒之后,自动跳转到首页…… </p> <script type="text/javascript"> var second = 5; var time = document.getElementById("time"); function showTime(){ second--; if(second <= 0){ location.href = "https://www.baidu.com"; } time.innerHTML = second + ""; } //设置定时器,1秒执行该方法 setInterval(showTime, 1000); </script> </body> </html>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。