[英]how can i make my page refresh only once?
Js: JS:
<script type="text/javascript">
function timedRefresh(timeoutPeriod) {
var refreshed=true;
if(refreshed){
refreshed=false;
setTimeout("location.reload();",timeoutPeriod);
}
}
</script>
Html HTML
body onload="JavaScript:timedRefresh(5000);" body onload =“JavaScript:timedRefresh(5000);”
i can not get it to load only once its keeps reloading instead of taking the new value 我只能在它不断重新加载而不是获取新值时才能加载它
重新加载页面将再次触发加载事件,这将再次重新加载页面...您应该使用cookie或其他客户端数据存储来了解页面是否已加载一次。
You are making the assumption that the browser is keeping the javascript variable values between each page load, but everything is flushed. 您假设浏览器在每个页面加载之间保留javascript变量值,但所有内容都被刷新。 You might want to use HTML5 local storage so that state is persisted between pages.
您可能希望使用HTML5本地存储,以便在页面之间保持状态。
See http://www.w3schools.com/html/html5_webstorage.asp 见http://www.w3schools.com/html/html5_webstorage.asp
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.