title: IFrame inside my webpage triggering blur event
body: <p>I have a countdown on my webpage along with an IFrame. Countdown will stop on <code>$(window).blur</code> and start on <code>$(window).focus</code>. When i click on the IFrame, it triggers the blur event and stops the countdown. I have solved this issues by following code line.</p>
  
  <pre><code> $(window).blur(function () {
    if (document.activeElement.nodeName == "IFRAME") {
      //Continue timer
      else {
          //Stop timer
      }
   });
  </code></pre>
  
  <p>But, When i click outside the window immediately after clicking inside IFrame, Blur event is not getting triggered. Since blur event will not be triggered after a blur event unless focus event is triggered.</p>
  
  <p>I have referred similar topics - <a href="https://stackoverflow.com/questions/16037671/window-blur-event-affecting-iframe?answertab=votes#tab-top">$(window).blur event affecting Iframe</a> and
  <a href="https://stackoverflow.com/questions/9880193/how-can-i-capture-the-blur-and-focus-of-the-entire-browser-window/17603566#17603566">How can I capture the blur and focus of the entire browser window?</a></p>
  
  <p>Any other Ideas?</p>
  
  <p><strong>Update</strong>- I did an another approach which lead me another step ahead. The following code is new approach </p>
  
  <pre><code>$(window).on('focus', function () {
                              //Coundown runs
                      }).on('blur', function () {
                              //Coundown stops
                      });;
  
   $(document).ready(function () {
                  var iframe = document.getElementById("iframeID");
                              $(iframe.contentWindow).on('focus', function (){
                                      //Coundown runs
                              }).on('blur', function () {
                                      //Coundown stops
                              });
                      });
  </code></pre>
  
  <p>This code will make countdown run on iframe focus and stop on iframe blur.</p>
  
  <p><strong>But</strong>, the issue i am facing in this approach is countdown working fine when "scr" not loaded in Iframe. if the "scr" is loaded in Iframe then focus and blur event for Iframe are not getting bind and countdown stops on Iframe click.</p>
  
  <p>Any idea on this?</p>