我在标题中使用以下 javascript 来刷新页面
<script type="text/JavaScript">
<!--
function timedRefresh(timeoutPeriod) {
setTimeout("location.reload(true);",timeoutPeriod);
}
// -->
</script>
在正文标签中
<body onload="JavaScript:timedRefresh(5000);">
我的问题是如何添加显示倒计时的文本以刷新页面
x 秒刷新
最佳答案
这符合您的需求吗?
(function countdown(remaining) {
if(remaining <= 0)
location.reload(true);
document.getElementById('countdown').innerHTML = remaining;
setTimeout(function(){ countdown(remaining - 1); }, 1000);
})(5); // 5 seconds
关于Javascript 刷新 + 倒计时文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16532577/