title: What's the topmost iframe in the same domain?
body: <p>How can I get the topmost iframe which is in the same domain, i.e.</p>
  
  <pre><code>iframe level 1 example.org
      iframe level 2 example.org
      iframe level 2 example.org 
          iframe level 3 example.org &lt;-- should return iframe level 1
  
  iframe level 1 other-example.org
      iframe level 2 example.org
      iframe level 2 example.org 
          iframe level 3 example.org &lt;-- should return iframe level 2
  
  iframe level 1 other-example.org
      iframe level 2 example.org
      iframe level 2 example.org &lt;-- should return iframe level 2 (this)
  </code></pre>
  
  <p>I need it because I have a website which should work in an iframe of another domain and stand-alone.</p>
  
  <p>In this website there are scripts which depend on window.top which shouldn't be top but the topmost iframe in the same domain.</p>