title: Detecting idle time in JavaScript across Tabs?
body: <p>I have written a script which detects the idle time in javascript and logs out user after 30 mins of inactivity. The script runs fine. But one thing where it will fail is if the user opens any of the page in new tab and is working on that page. The script on previous tab will still run and log the user out of both the tabs. What could be possible solution to preserve the idle time detection across Tabs.</p>
  
  <p><pre><code>var time = new Date().getTime();
                  $(document.body).bind("mousemove keypress", function(e) {
                      time = new Date().getTime();
                  });</p>
  
  <pre><code>     function refresh() {
           if(new Date().getTime() - time &gt;= 6000) {
               $('#edit-quote-details').modal('show');
           clock = $('.clock').FlipClock(61,{
                  clockFace: 'MinuteCounter',
                  countdown: true,
                  callbacks: {
                      stop: function() {
                          window.location.href='../logout.action';
                      }
                  }
              });
           }
           else {
               setTimeout(refresh, 10000);
           }
       }
  
       setTimeout(refresh, 10000); 
  </code></pre>
  
  <p></code>
  </pre></p>