如何防止我的网站页面通过iFrame的第三方网站框架加载 [英] How to prevent my site page to be loaded via 3rd party site frame of iFrame

查看:224
本文介绍了如何防止我的网站页面通过iFrame的第三方网站框架加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在页面加载期间找到我的页面作为框架嵌入到其他网站?我猜引用请求标题无法帮助我吗?谢谢。

How can I find out that my page is embedded as a frame to other site during page loading? I guess referrer request header can't help me here? Thanks.

推荐答案

您无法从服务器端检查它,但您可以在页面加载后使用javascript检测它。比较顶部自我,如果它们不相同,则表示你在一个框架内。

You cannot check it from the server's side, but you can use javascript to detect it after the page has loaded. Compare top and self, if they're not identical, you are in a frame.

此外,一些现代浏览器尊重 X-FRAME-OPTIONS 标头,它可以有两个值:

Additionally, some modern browsers respect the X-FRAME-OPTIONS header, that can have two values:


  • DENY - 阻止页面包含在框架中时呈现页面

  • SAMEORIGIN - 与上面相同,除非页面属于与顶级框架集持有者相同的域。

用户包括Google的Picasa,无法嵌入框架中。

Users include Google's Picasa, that cannot be embedded in a frame.

支持标题的浏览器,最小版本:

Browsers that support the header, with the minimum version:


  • IE8和IE9

  • Opera 10.50

  • Safari 4

  • Chrome 4.1.249.1042

  • Firefox 3.6.9(使用 NoScript 的旧版本)

  • IE8 and IE9
  • Opera 10.50
  • Safari 4
  • Chrome 4.1.249.1042
  • Firefox 3.6.9 (older versions with NoScript)

这篇关于如何防止我的网站页面通过iFrame的第三方网站框架加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆