自动跳转至首页(Java Script)
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<title>Java Script Test Place</title>
<style>
p{
text-align: center;
}
#count{
color: red;
}
</style>
</head>
<body>
<p><span id="count">10</span>秒后自动跳转至首页!</p>
<script>
var second=10;
var count=document.getElementById("count");
function countDown(){
if(second<=0){
location.href="https://www.baidu.com";
return;
}
second--;
count.innerHTML=second.toString();
}
window.setInterval(countDown, 1*1000);
</script>
</body>
</html>