Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript window.setInterval(function() Need help Reply To: window.setInterval(function() Need help

#191845
tarnos12
Participant

Thing is, there is nothing that “start” this interval…it just works on its own.

window.setInterval(function()
{

if (health + hpregen >= maxhealth)
{
    health = maxhealth;
    document.getElementById('health').innerHTML = health;
}
else if (health + hpregen < maxhealth)
{
    health = health + hpregen;
    document.getElementById('health').innerHTML = health;

}
}, 1000);

thats all :> there are just global variables.