I have a moneycounter that shows the amount of money somebody makes per decisec. It works fine but when I switch to another tab or minimize the webpage, the the counting stops. When I come back on the page the counter just resumes. I have not found a similair topic yet, does anybody know how to fix this?
<script>
window.onload = function(){
document.getElementById("maandmoney").value = 2000;
}
var money=0;
var r;
var moneypdsec;
var timer=setInterval(function(){moneyTimer()},100);
function moneyTimer() {
r = document.getElementById("maandmoney").value;
moneypdsec = r / 26297438.3;//months to decisec
money += moneypdsec;
document.getElementById("counter").innerHTML = money.toFixed(4);
}
function salaris() {
money = 0;
r = document.getElementById("maandmoney").value;
}
</script>
<textarea id="maandmoney"></textarea>
<div id="reset"><a href="" onClick="salaris();return false;">R</a> </div>
<p id="counter">0</p>