title: How to prevent IFRAME from redirecting top-level window
body: <p>Some websites have code to "break out" of <code>IFRAME</code> enclosures, meaning that if a page <code>A</code> is loaded as an <code>IFRAME</code> inside an parent page <code>P</code> some Javascript in <code>A</code> redirects the outer window to <code>A</code>.</p>
  
  <p>Typically this Javascript looks something like this:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
    if (top.location.href != self.location.href)
       top.location.href = self.location.href;
  &lt;/script&gt;
  </code></pre>
  
  <p>My question is: As the author of the parent page <code>P</code> and not being the author of the inner page <code>A</code>, how can I prevent <code>A</code> from doing this break-out?</p>
  
  <p>P.S. It seems to me like it ought to be a cross-site security violation, but it isn't.</p>