I have function in my code, which suppose to gradually decrease the refreshment of the page from 50 sec to 10 if the button is pressed. Here it is:
<div id="signin" onclick="pgeReload()"></div>
....
<script type="text/javascript">
var count=0;
function pgeReload(){
if(count <= 4){
count++;
}
var times = count*10000;
var pospond = 50000-count;
setTimeout(function(){window.location.reload()}, pospond);
}
</script>
My problem is that the reload of the page always occurs after 50 seconds because (if I got it correctly) the variable count
is always reassigned to 0 when the page reloads.
My Question is can I retain the value of count after it has been incremented even after the refresh of the page?
thank you very much for everyone who can help me with that.
the version with html5. But still, the problem is the initial value. The count is always 0
<script type="text/javascript">
var count=0;
function pagereload(){
if(typeof(Storage)!=="undefined")
{
count++;
window.content.localStorage[key]=count;
var tempTime = parseInt(window.content.localStorage[key])*1000;
var pospond = 50000-tempTime;
setTimeout(function(){window.location.reload()}, pospond);
}
else{
setTimeout(function(){window.location.reload()}, 30000);
}
</script>