title: How do I make page refresh happen each time person leaves (window blur) then comes back (window focus)?
body: <p>Having trouble with this. I want page to refresh when you leave page then come back. At first I got it to work for chrome and firefox, but not ie and edge. Then I tweaked it some more and got it to work in edge. ie is the only one having issue. no matter what i do, ie goes into an infinite loop of refreshing. i even put things in to make it happen only once, like using the "one" function in jquery, which is how it started working in edge, but ie didn't care about that rule. then i tried a hash technique where it only does it if no hash in url, so it refreshes adding hash then next load doesn't refresh because there is hash, but that only works once. i can't figure out how to reset hash so it can happen again. i figured out how to make it reverse each time, so it does it when no hash then next time is does it when hash, but again it works in all browsers except ie. ie keeps refreshing infinitely. here is all the code and all the different things i tried commented out. i don't need it to refresh on leaving, just coming back. on every come back.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).one('ready',function(){
  $(window).one('load',function(){
   
   $(window).blur(function(e)
   //$(window).one('blur',function(e)
   {
    // Do Blur Actions Here
    console.log('left'); //test
    //if(window.location.hash) {
     // # exists in URL
     //if (typeof window.history.replaceState == 'function') {
      //history.replaceState({}, '', window.location.href.slice(0, -1));
     //}
    //}
   });
   
   $(window).focus(function(e)
   //$(window).one('focus',function(e)
   {
    // Do Focus Actions Here
    console.log('came back'); //test
    
    //if(document.URL.indexOf("#")==-1){ //Check if the current URL contains '#'
     //console.log('no hash');
     //url = document.URL+"#"; // use "#". Add hash to URL
     //location = "#";
     //location.reload(true); //Reload the page
     //console.log(url);
    //}
    //else {
     //console.log('has hash');
     //if (typeof window.history.replaceState == 'function') {
      //if (history.replaceState({}, '', window.location.href.slice(0, -1))){
       //url = document.URL;
       //location.reload(true);
       //console.log(url);
      //}
     //}
    //}
    
    location.reload(true);
    
   });
   
   //$(function(){
    //$(window).bind('blur', function(){
     //console.log('window blur');
    //});
  
    //$(window).bind('focus', function(){
     //console.log('window focus');
    //});
    
    // IE EVENTS
    //$(document).bind('focusout', function(){
     //console.log('document focusout');
    //});
  
    //$(document).bind('focusin', function(){
     //console.log('document focusin');
     //location.reload(true);
     //$(document).unbind( "focusin", handler );
     //$(document).unbind( "focusout", handler );
     //$(document).unbind( "blur", handler );
     //$(document).unbind( "focus", handler );
    //});
   //});
   
   //if(window.location.hash) {
    //window.location.href.substr(0, window.location.href.indexOf('#'));
    //window.location.href.split('#')[0];
    //console.log('has hash');
   //}
   //history.pushState("", document.title, window.location.pathname);
   
   // remove fragment as much as it can go without adding an entry in browser history:
   //window.location.replace("#");
   // slice off the remaining '#' in HTML5:    
   //if (typeof window.history.replaceState == 'function') {
    //history.replaceState({}, '', window.location.href.slice(0, -1));
   //}
  });
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt;
  
  page stuff.
  
  click outside this area then back in this area over and over. that simulates leaving and coming back.</code></pre>
  </div>
  </div>
  </p>