页面加载调用倒计时js
<script type="text/javascript">
window.onload = function () {
timeDisplay("1", "12", "0", "0");
}
</script>
倒计时js
<pre name="code" class="javascript"><script type="text/javascript">
var timeDisplay = function (day, hour, minutes, seconds) {
var d = day, h = hour, m = minutes, s = seconds;
s--;
if (s < 0) {
s = 59; m--;
if (m < 0) {
m = 59; h--;
if (h < 0) {
h = 23; d--;
if (d < 0)
{ window.setTimeout("window.location='" + window.location.href + "';", 990); }
}
}
}
document.getElementById("refreshDays").innerHTML = d;
document.getElementById("refreshHours").innerHTML = h;
document.getElementById("refreshMinutes").innerHTML = m;
document.getElementById("refreshSeconds").innerHTML = s;
window.setTimeout("timeDisplay(" + d + "," + h + "," + m + "," + s + ")", 990);
}
</script>
页面调用方法
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<form id="form1">
<div>
距离当期开奖时间还剩:<span id="refreshDays">0</span>天<span id="refreshHours">0</span>小时<span id="refreshMinutes">0</span>分<span id="refreshSeconds">0</span>秒
</div>
</form>
</body>
</html>