[X]

Break Out Of Frames

navigation 1997 still works

Forces your page to the top window if somebody loads it inside their frameset.

In 2026: Still works and is still the right idea. The modern equivalent is the X-Frame-Options or frame-ancestors header, which a script cannot be talked out of.

Where it came from: Circulated widely from about 1997, once people started framing other people's sites. MDN

<script language="JavaScript">
if (top.location != self.location) {
  top.location = self.location.href;
}
</script>

<!-- The 2026 version. Send this as an HTTP response header instead: -->
<!-- Content-Security-Policy: frame-ancestors 'self' -->
sandboxed demo · breaks nothing but itselfrestart

More in navigation

all 7 in navigation › · the whole library ›