title: Gain focus on tab if it's blured by javascript
body: <p>After I get some event form server, I want to gain focus on my tab if it is blured...
  But, as I know, window.focus() method is blocked for some reasons... </p>
  
  <p>I managed to achieve this effect, but the method I developed uses a kind of bad aproach, what it does is that, when the event comes, detects if my tab is blured, opens same tab from the very beggining by window.open and closes actual tab... for better understanding here is an example:</p>
  
  <pre><code>$(window).focus(function() {
      focused = true;
  });
  $(window).blur(function() {
      focused = false;
  
      setInterval(function() {
              if (!focused) 
              {
                  window.open("example.html","_blank");
                  window.close();
              }
      },5000);
  });
  </code></pre>
  
  <p>if you have any better way to achieve this, I would be grateful...</p>
  
  <p>With all the respect,</p>
  
  <p>Ratty</p>