如何在页面加载期间发现我的页面作为框架嵌入到其他站点?我猜推荐人请求标头在这里帮不了我?谢谢.
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 来检测它.比较top
和self
,如果它们不相同,你就在一个框架中.
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:
用户包括无法嵌入框架的 Google 的 Picasa.
Users include Google's Picasa, that cannot be embedded in a frame.
支持header的浏览器,最低版本:
Browsers that support the header, with the minimum version:
这篇关于如何防止我的网站页面通过 iFrame 的第 3 方网站框架加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!