title: How to fool Iframe that it is top most window
body: <p>I wonder, is there a way to override the iframe's window.top and window.parent such that from it's context the following is true </p>
  
  <pre><code>window === window.parent &amp;&amp; window === window.top
  </code></pre>
  
  <p>The case is that the app that I want to embed in an iframe has many references to window.top, it stores objects and uses them to communicate back and forth with its own child iframes.</p>
  
  <pre><code>&lt;iframe sandbox=""&gt;&lt;/iframe&gt;
  </code></pre>
  
  <p>Without "allow-scripts" is not an option for me as any access to window.top throws and Error, while I want things to work pretty much as if the iframe was a top level window</p>
  
  <p>Note:
  I saw a similar question asked <a href="https://stackoverflow.com/questions/4384885/how-to-trick-fool-an-iframe-to-thinking-its-the-top-element-in-dom">How to Trick/Fool an Iframe to thinking its the TOP element in DOM</a> but there while the same requirement, the actual problem - changing the top.location could be worked-around, this is why I guess the discussion was discontinued. </p>