setTimeout只会执行一次,所以,,,,
要想一直让他工作,要么用计时器
setInterval(function(){window.location.reload()
},5000)
要么这样
function refresh(){window.location.reload()
setTimeout(refresh , 5000)
}
<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>
首先,当页面渲染完成后,记录历史的值
var historyVal = $('#jiance').html()
每隔5秒执行检测
setInterval(function() {
notifyme()
}, 5000)// 5000表示5000毫秒, 即每隔5秒执行一次