Skip to content

Instantly share code, notes, and snippets.

@idmontie
Last active March 17, 2018 20:34
Show Gist options
  • Save idmontie/620219b89db47f9324cc23dd72ca795c to your computer and use it in GitHub Desktop.
Save idmontie/620219b89db47f9324cc23dd72ca795c to your computer and use it in GitHub Desktop.
Make sure you aren't iframed!
<!-- Crazy, but consistent method: -->
<style>
body { display: none; }
</style>
<script>
if (self === top) {
documents.getElementsByTagName("body")[0].style.display = 'block';
} else {
top.location = self.location;
}
</script>
<!-- Inconsistent method: -->
<script>
if (top.location != location) {
top.location = self.location;
}
</script>
X-Frame-Options: DENY prevents framing code at all
X-Frame-Options: SAMEORIGIN prevents framing by external sites
X-Frame-Options: ALLOW-FROM origin allows framing only by the specified origin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment