title: Most current framebusting javascript?
body: <p>I need to add a javascript-based framebuster for my web application that helps prevent clickjacking (or Cross Frame Scripting) attacks for legacy browsers that don't support X-FRAME-OPTIONS.</p>
  
  <p>After searching the internet, I found that currently there seems to be two approaches, shown below. Being a complete newbie at javascript, I prefer approach 1 for its simplicity..</p>
  
  <p><strong>My question is</strong> - are both approaches still valid at this time or is any of them already "busted"?</p>
  
  <p>EDIT: changed my question to ask about both approaches instead of just approach 1.</p>
  
  <p>Approach 1 (from <a href="http://en.wikipedia.org/wiki/Framekiller#Modern_framekiller" rel="nofollow">http://en.wikipedia.org/wiki/Framekiller#Modern_framekiller</a>):</p>
  
  <pre><code>if (self == top) {
      document.documentElement.style.display = 'block';
  } else {
      top.location = self.location;
  }
  </code></pre>
  
  <p>Approach 2 (from <a href="https://www.owasp.org/index.php/Clickjacking_Defense_Cheat_Sheet#Best-for-now_Legacy_Browser_Frame_Breaking_Script" rel="nofollow">https://www.owasp.org/index.php/Clickjacking_Defense_Cheat_Sheet#Best-for-now_Legacy_Browser_Frame_Breaking_Script</a>):</p>
  
  <pre><code>&lt;style id="antiClickjack"&gt;body{display:none !important;}&lt;/style&gt;
  &lt;script type="text/javascript"&gt;
     if (self === top) {
         var antiClickjack = document.getElementById("antiClickjack");
         antiClickjack.parentNode.removeChild(antiClickjack);
     } else {
         top.location = self.location;
     }
  &lt;/script&gt;
  </code></pre>
  
  <p>Many thanks.</p>