js循环倒计时代码 每5秒循环倒计时到0 再从5秒开始 到0之后刷新页面 类似网易的滚动新闻 20
3个回答
展开全部
<html>
<head>
<title> JS时间循环</title>
<script type="text/javascript">
window.onload = function(){
showTime(1);
}
var seconds = 5;
function showTime(time)
{
document.getElementById("time_div").innerHTML = seconds;
if(seconds >= 0)
{
seconds--;
}
else{
seconds = 5;
window.location.reload();
}
setTimeout("showTime()",1000);
}
</script>
</head>
<body>
<div id="time_div"></div>
</body>
</html>
<head>
<title> JS时间循环</title>
<script type="text/javascript">
window.onload = function(){
showTime(1);
}
var seconds = 5;
function showTime(time)
{
document.getElementById("time_div").innerHTML = seconds;
if(seconds >= 0)
{
seconds--;
}
else{
seconds = 5;
window.location.reload();
}
setTimeout("showTime()",1000);
}
</script>
</head>
<body>
<div id="time_div"></div>
</body>
</html>
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<div id="d1">5</div>
<script>
var se = parseInt(document.getElementById("d1").innerHTML);
window.onload = function() {
setTimeout("timers()",1000);
}
function timers() {
document.getElementById("d1").innerHTML = (se - 1) == 0 ? "0" : (se - 1);
se--;
if (se == 0) {
window.location.reload();
} else {
setTimeout("timers()",1000);
}
}
</script>
<script>
var se = parseInt(document.getElementById("d1").innerHTML);
window.onload = function() {
setTimeout("timers()",1000);
}
function timers() {
document.getElementById("d1").innerHTML = (se - 1) == 0 ? "0" : (se - 1);
se--;
if (se == 0) {
window.location.reload();
} else {
setTimeout("timers()",1000);
}
}
</script>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<span class="style33" id="spanSeconds"><%=time %></span> 秒
<script type="text/javascript">
var spanSeconds = document.getElementById("spanSeconds");
var second = 5;
function setSecond()
{
second--;
if(second < 0)
{
this.location.href =this.location.href;
}
else
{
spanSeconds.innerHTML = second;
}
}
setInterval("setSecond()",1000);
</script>
<script type="text/javascript">
var spanSeconds = document.getElementById("spanSeconds");
var second = 5;
function setSecond()
{
second--;
if(second < 0)
{
this.location.href =this.location.href;
}
else
{
spanSeconds.innerHTML = second;
}
}
setInterval("setSecond()",1000);
</script>
追问
要和这个http://news.163.com/latest/一样的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询