JavaScript制作倒计时页面,倒计时5秒跳转至六思逸官网
六思逸 发布于 阅读:1379 JavaScript
效果图
完整代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>六思逸</title>
<style>
#box {
position: fixed;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 200px;
height: 200px;
line-height: 200px;
text-align: center;
background-color: black;
color: white;
font-size: 50px;
font-weight: bold;
border-radius: 50%;
}
</style>
</head>
<!-- 制作一个倒计时5秒钟的页面,时间显示为0时跳转到六思逸) -->
<body>
<div id="box"></div>
<script>
function box(num) {
document.getElementById('box').innerHTML = num;
let timer = window.setInterval(function () {
num--;
console.log(num)
document.getElementById('box').innerHTML = num;
if (num <= 0) {
window.location.href = 'https://www.6s1.cn/'
window.clearInterval(timer)
}
}, 1000);
}
box(5)
</script>
</body>
</html>
版权所有:六思逸
文章标题:JavaScript制作倒计时页面,倒计时5秒跳转至六思逸官网
文章链接:https://6s1.cn/post-45.html
本站文章均为原创,未经授权请勿用于任何商业用途
文章标题:JavaScript制作倒计时页面,倒计时5秒跳转至六思逸官网
文章链接:https://6s1.cn/post-45.html
本站文章均为原创,未经授权请勿用于任何商业用途
扫描二维码,在手机上阅读