Hi in my javascript i need to increase an int value by one after every 5 seconds. How to do this? The script should keep increasing until the user moves away from the page.

This could be easily done using the setInterval() method.

Simple example...

<span id="total">0</span>

<script>
var x = 0;
var int=self.setInterval(function(){count()},5000);

function count(){
  x++;
  document.getElementById("total").innerHTML=x;
}
<script>

Try on jsFiddle

commented: Thanks +3