繁体   English   中英

如何阻止我的网站被他人陷害?

[英]How to stop my website being framed by others?

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

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

Google.com 不会加载,msn.com 会跳出框架。 AOL.com 将正常加载。 如何让我的网站跳出框架或加载整个窗口?

这个小脚本片段应该可以工作:

<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

如果将顶部框架的 url 与当前框架 url 进行比较,则可以完成跳出框架脚本:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM