![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/8e09607ce633b605185a2c218a4d964d.jpeg)
上代码
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div id="demo"></div>
</body>
</html>
<script>
var demo=document.getElementById("demo");
var count=5;
setTimeout(goIndex,1000);
function goIndex(){
count--;
demo.innerHTML="<a href='http://www.baidu.com'>本页面将在"+count+"秒后跳转至主页</a>";
if(count<0){
window.location.href="http://www.baidu.com";
}else{
setTimeout(goIndex,1000);
// setTimeout(arguments.callee,1000); 另外一种写法 arguments.callee调用自身的函数
}
}
</script>