样图
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
div{
width: 200px;
height: 30px;
position: absolute;
left: 0px;
right: 0px;
margin: auto;
background-color: aqua;
text-align: center;
}
</style>
</head>
<body >
<div id="sp">
</div>
</body>
<script type="text/javascript">
onload = function(){
setInterval(go,1000);
};
var x = 4;
function go(){
x--;
if(x>0){
document.getElementById("sp").innerHTML = "经过"+x+"秒后跳转页面";
}else{
location.href = "https://www.baidu.com";
}
}
</script>
</html>