如何阻止我的网站被别人诬陷?

时间:2012-10-31 23:39:43

标签: javascript iframe xss

如何阻止我的网站加载到框架中?

从这里可以看出: http://yehg.net/lab/pr0js/pentest/cross_site_framing.php

Google.com无法加载,msn.com将突破框架。 AOL.com将加载罚款。如何让我的网站突破框架或加载整个窗口?

3 个答案:

答案 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)

答案 2 :(得分:0)

如果您将顶部框架的网址与当前框架网址进行比较,则可以执行突破框架脚本:

if(window.top.location.href != window.href)
{
  window.top.location = window.href;
}