title: Redirect from iFrame using javascript or Jquery
body: <p>If a website is loaded into an iframe, what code do I need to put on the child page of that iFrame to break out of the iFrame and load that page as the top document or reidrect to that page</p>
  
  <p>Just found the code</p>
  
  <pre><code>&lt;script&gt;
  if(window.top !== window.self){
  window.top.location.href = "http://www.blah.com"; 
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>Even better code:</p>
  
  <pre><code>&lt;style&gt; html{display : none ; } &lt;/style&gt;
  &lt;script&gt;
     if( self == top ) {
         document.documentElement.style.display = 'block' ; 
     } else {
         top.location = self.location ; 
     }
  &lt;/script&gt;
  </code></pre>
  
  <p>Code Example below:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
  blah
  &lt;/head&gt;
  &lt;body&gt;
  &lt;iframe src="www.blah.com"&gt;&lt;/iframe&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>What JQuery or javascript do I need to put on (in this example) www.blah.com so it breaks out of the iframe and www.blah.com is directly shown to the user?</p>