Break Out of Frames Script

Empower your users to escape unwanted framesets. This script generates a link that, when clicked, breaks the current page out of any frame and displays it in the full browser window.

Interactive Escape Demo

Simulated Frame Environment:

Note: Clicking this will reload this page at the top level.

Copy the Script

<script>
  if (window.top !== window.self) {
    document.write('<a href="' + window.self.location.href + '" target="_top">Click here to break out of frames</a>');
  }
</script>

Frequently Asked Questions

Modern browsers allow parent frames to set "sandbox" attributes that can block top-level navigation, but for the majority of standard framesets, this script works perfectly.

You can add a CSS class to the document.write string (e.g., class="myButton") and define the styles in your main CSS file.

Yes. Check out our Keep Page Out of Frames script if you want to automatically redirect without user interaction.