<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<p>还有<span id="second"></span>秒自动跳转到 <a href="http://www.baidu.com"><span id="link">百度首页</span></a> </p>
</body>
<script>
var time = 5;
function upTime(){
document.querySelector('#second').innerHTML = time;
time--;
if(time == 0){
document.querySelector('#link').click();
clearInterval(timer)
}
}
timer = setInterval('upTime()',1000)
</script>
</html>