Created
November 25, 2014 04:01
-
-
Save kiinlam/5b52b40bbc6c99eda37b to your computer and use it in GitHub Desktop.
防止网页被嵌入框架的代码
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
/* | |
* 作者: 阮一峰 http://www.ruanyifeng.com/ | |
* http://www.ruanyifeng.com/blog/2010/08/anti-frameset_javascript_codes_continued.html | |
*/ | |
try{ | |
top.location.hostname; | |
if (top.location.hostname != window.location.hostname) { | |
top.location.href =window.location.href; | |
} | |
} | |
catch(e){ | |
top.location.href = window.location.href; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment