jquery - Mouseenter and Mouseleave to trigger timer on/off -


how code mouseenter event trigger timer off , mouseleave event trigger timer on?

if timer interval reached webpage refresh.

i've tried couldn't work out:

<script>   $(document).ready(function() {     var timer;    function start() {      timer = setinterval(function(){refresh()}, 5000);   }     start();    $('body').mouseenter(function() {      cleartimeout(timer);   });   }).mouseleave(function(e) {      var pagex = e.pagex || e.clientx,          pagey = e.pagey || e.clienty;       if (pagex <= 0 || pagey <= 0) {         start();     }     else     cleartimeout(timer);   });     function refresh() {      window.location.reload(true);   });  </script> 

(this code partially taken here: https://stackoverflow.com/a/17714300/2593839)

this code should work :

function refresh() {    window.location.reload(true); }  var timer; function start() {   timer = settimeout(function(){refresh()}, 5000); }  jquery(document).ready(function() {   start();    jquery('body').mouseenter(function() {      cleartimeout(timer);   }).mouseleave(function(e) {      var pagex = e.pagex || e.clientx,          pagey = e.pagey || e.clienty;        if(pagex <= 0 || pagey <= 0) {         start();       }else {         cleartimeout(timer);       }   }); }); 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -