<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>网页跳转</title>
<style>
p{
text-align: center;
}
span{
color:red;
}
</style>
</head>
<body>
<p> <span id="s" >5</span>秒后跳转到百度</p>
<script>
var s=5;
var time = document.getElementById("s");
function show() {
s--;
if (s<1){
location.
clearImmediate(id)
}
time.innerHTML=s+"";
}
var id = setInterval(show,1000);
</script>
</body>
|
|