<body>
<script>
var interval = 1000
var year=2005
var month=4
var day=10
var divname="sj"
function ShowCountDown(year,month,day,divname)
{
var now = new Date()
var endDate = new Date(year, month-1, day)
var leftTime=endDate.getTime()-now.getTime()
var leftsecond = parseInt(leftTime/1000)
//var day1=parseInt(leftsecond/(24*60*60*6))
var day1=Math.floor(leftsecond/(60*60*24))
var hour=Math.floor((leftsecond-day1*24*60*60)/3600)
var minute=Math.floor((leftsecond-day1*24*60*60-hour*3600)/60)
var second=Math.floor(leftsecond-day1*24*60*60-hour*3600-minute*60)
var cc = document.getElementById(divname)
cc.innerHTML = "距离"+year+"年"+month+"月"+day+"日还有:"+"<br>"+day1+"天"+hour+"小时"+minute+"分"+second+"秒"
}
setInterval("ShowCountDown(year,month,day,divname)",100)
</script>
<div id="sj"></div>
</body>
</html>
<!DOCTYPE html><html>
<head>
<meta charset="UTF-8">
<title>倒计时五秒后跳页面</title>
<script>
function countDown(){
//获取初始时间
var time = document.getElementById("Time")
//获取到id为time标签中的数字时间
if(time.innerHTML == 0){
//等于0时清除计时,并跳转该指定页面
window.location.href="https://mbd.baidu.com/newspage/data/landingshare?pageType=1&isBdboxFrom=1&context=%7B%22nid%22%3A%22news_8894402723098202660%22%2C%22sourceFrom%22%3A%22bjh%22%7D"
}else{
time.innerHTML = time.innerHTML-1
}
}
//1000毫秒调用一次
window.setInterval("countDown()",1000)
</script>
<style>
#Time,#p{
font-size: 150px
text-align: center
}
#Font,#p{
font-size: 100px
text-align: center
}
</style>
</head>
<body>
<font color="yellow"><p id="Time" >20</p></font>
<p id="Font">20秒后将跳转至主页</p>
</body>
</html>
记得保存成xxx.html ,然后使用浏览器打开就可以实现了
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)