title: Detect window visibility if inside cross domain iframe
body: <p>If a web page <strong>A</strong> is rendered in an <code>&lt;iframe&gt;</code> inside a <em>cross-domain</em> web page <strong>B</strong>, how to know when <strong>A</strong> is visible in <strong>B</strong>?</p>
  
  <p>For example, if web page <strong>A</strong> is far below in the document scroll of <strong>B</strong> and the user has to scroll down to see it, how to know when the user has scrolled down enough to see the <code>&lt;iframe&gt;</code>.</p>
  
  <p><a href="https://i.stack.imgur.com/dOjeC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dOjeC.png" alt="enter image description here"></a></p>
  
  <p>There is only control/access to web page <strong>A</strong>.</p>
  
  <p>Because of <a href="https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy" rel="nofollow noreferrer">Same-Origin Policy</a>, there is no access to events or calculations to get this data.</p>
  
  <p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API" rel="nofollow noreferrer">Page Visibility API</a> only informs when a web page is browser tab active.</p>