如何阻止我的网站加载到框架中?
从这里可以看出: http://yehg.net/lab/pr0js/pentest/cross_site_framing.php
Google.com无法加载,msn.com将突破框架。 AOL.com将加载罚款。如何让我的网站突破框架或加载整个窗口?
答案 0 :(得分:9)
这个小脚本片段应该可以工作:
<script>
if (window !== top) top.location = window.location;
</script>
此外,您可以通过指定X-Frame-Options: DENY
标题来阻止您的网页加载到iframe中。有关详细信息,请参阅https://developer.mozilla.org/en-US/docs/The_X-FRAME-OPTIONS_response_header。
答案 1 :(得分:1)
这些可能会指向正确的方向...或谷歌'突破iframe'?
Frame Buster Buster ... buster code needed
Detect iFrame embedding in Javascript
How to identify if a webpage is being loaded inside an iframe or directly into the browser window?
答案 2 :(得分:0)
如果您将顶部框架的网址与当前框架网址进行比较,则可以执行突破框架脚本:
if(window.top.location.href != window.href)
{
window.top.location = window.href;
}