mercredi 5 avril 2017

Ignore page refresh if there are youtube videos inside the page

I use this script to auto refresh page when users are inactive on my website.

<script>
 var time = new Date().getTime();
 $(document.body).bind("mousemove keypress", function(e) {
     time = new Date().getTime();
 });

 function refresh() {
     if(new Date().getTime() - time >= 60000) 
         window.location.reload(true);
     else 
         setTimeout(refresh, 10000);
 }

 setTimeout(refresh, 10000);
</script>

I need to exclude the auto refresh if in my page there are youtube videos. Youtube video are always inside #player CSS id.

Aucun commentaire:

Enregistrer un commentaire