title: jQuery or JavaScript - set back the focus to a body element once it is in a cross domain iframe
body: <p>I am facing the problem, that has been already asked but not exactly as I am going to do (or I haven't found it), about knowing when someone clicks into a cross domain iframe on which I have no control.<br /><br />
  I have seen there are some tricks to get it: I do that, and it works  on FF, IE 11 and Chrome, listening to a focusout() event; anyway it works only the first time someone clicks on the iframe.<br /><br />
  Now, to know if the user clicks again, when this event happens, I have tried to get back the focus on an element inside the body of my document, but this doesn't work.<br /><br />Here is the code I have written:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  
      &lt;head&gt;
  
          &lt;title&gt;Focus() test&lt;/title&gt;
  
          &lt;!-- JQuery libraries --&gt;
          &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"&gt;&lt;/script&gt;
  
      &lt;/head&gt;
  
      &lt;body&gt;
  
          &lt;input type="text" id="myInput" value=""&gt; &lt;br /&gt;
  
          &lt;div id="iframeContainer" style="height: 400px; width: 280px"&gt;
              &lt;iframe id="theIframe" height="400px" width="280px" src="https://docs.google.com/viewer?srcid=0B3R3uQMMhRrxUFJyYllhd0hVSkk&amp;pid=explorer&amp;efh=false&amp;a=v&amp;chrome=false&amp;embedded=true"&gt; &lt;/iframe&gt;
          &lt;/div&gt;
  
          &lt;script&gt;
  
              var clickNum = 0;
  
              $(document).ready(function(){
                  $("#myInput").focus();
                  $("body").focusout(function() {
                      clickNum++;
                      alert("click num:" + clickNum);
                      $("#myInput").focus();
                  });
              });
  
          &lt;/script&gt;
  
      &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>I also tried substituting the last line of jQuery code i.e.</p>
  
  <pre><code>$("#myInput").focus();
  </code></pre>
  
  <p>with several instances of:</p>
  
  <pre><code>$(this).next().focus();
  </code></pre>
  
  <p>trying to simulate the tab key.<br />
  As a matter of fact, when someone clicks in the iframe (in my code on one of the zoom control of Google Drive preview), the focus is lost by the body and the alert is fired, but then I can't get back the focus on, for example, the input field.<br />
  But if someone press the tab key for a certain number of times (it depends on which zoom control one has previously clicked and with which order) the focus is back on the input field, or obviously, directly if someone clicks inside it.<br />
  Then if someone clicks again on one zoom control, the alert is fired again and you can trace the number of clicks.<br /><br />
  So my final question is:<br /><br />
  <strong>Is there a way to get back the focus from a cross domain iframe once the focus has gone on it or, when you can't control both documents in cross domains as in my case, you don't have any hope to get it back?</strong><br /><br /> 
  I know that these things have been maybe already asked, but I just found pieces of my whole question and not always with the exact same context. <br /><br />
  Thank you in advance,<br />
  Federico </p>