Twitter.com Frame Escaping Code

<script>
function bust () {
  document.write = "";
  window.top.location = window.self.location;
  setTimeout(function() {
    document.body.innerHTML = '';
    }, 0);
  window.self.onload = function(evt) {
    document.body.innerHTML = '';
  };
}
if (window.top !== window.self) { // are you trying to put self in an iframe?
  try {
    if (window.top.location.host) { // this is illegal to access unless you share a non-spoofable document domain
      // fun times
    } else {
      bust(); // chrome executes this
    }
  } catch (ex) {
    bust(); // everyone executes this
  }
}
</script>

One Response to “Twitter.com Frame Escaping Code”

  1. [...] stuff about the twitter frame busting code is just so I don’t lose that snippet of code.  Plus, I suppose it might be useful to [...]

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>