Created
April 23, 2012 12:08
-
-
Save johnathan-sewell/2470535 to your computer and use it in GitHub Desktop.
JavaScript iframe breakout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var isFrame; | |
try { | |
if (top.location.href !== window.location.href) { | |
isFrame = true; | |
} | |
} catch (e) { | |
// if you're in an iframe in a different domain, the top.location check | |
// results in a security exception | |
isFrame = true; | |
} | |
if (isFrame){ | |
//if (window.name !== "CMS_Frame") //don't break out of this one | |
window.parent.location.href = window.location.href; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment