Refresh page when user is away and there are no videos on page

4

I need to refresh the page of my site when the user is inactive for 15 minutes and when there are no videos embedded in it.

If the user is left inactive on a site page for 15 minutes, the page should be updated, but can not update if the page has some embedded youtube video.

Whenever there is an embedded video it will use this code:

<iframe width="1280" height="720" src="https://www.youtube.com/embed/*VIDEOID*"frameborder="0" allowfullscreen></iframe>
    
asked by anonymous 12.09.2017 / 18:28

1 answer

5

Only with php / html you can not do this, but here's an example of doing with javascript / jquery:

<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script><script>varidleTime=0;$(document).ready(function(){//Incrementtheidletimecountereveryminute.if($('iframe').length<1)//casonãoexistaiframevamosincrementarocontador(idleTime)de1em1minutovaridleInterval=setInterval(timerIncrement,60000);//1minutos//resetamosocontadorcasosejamdetetadosesteseventos$(this).mousemove(function(e){idleTime=0;});$(this).keypress(function(e){idleTime=0;});$(window).on('scroll',function(e){idleTime=0;});});functiontimerIncrement(){idleTime=idleTime+1;if(idleTime>14){//15minuteswindow.location.reload();}}</script>

Adaptedexample from here

If you did not need to detect some activity on the page, it would suffice in head of your html:

<meta http-equiv="refresh" content="900">

At what content is the number of seconds before refresh

    
12.09.2017 / 18:52