如何检查您的文档是否在IFrame中打开? [英] How can you check if your document is opened in an IFrame?

查看:91
本文介绍了如何检查您的文档是否在IFrame中打开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法知道您的网页是否在 IFrame 中打开?

Is there a way to know if your page is opened inside of an IFrame?

我的想法是看窗口对象是否有 .parent 属性,但这显然也适用于由Javascript的 window.open()函数打开的独立窗口。

An idea I had was to see if the window object has a .parent property, but this apparently is also true of standalone windows which are opened by Javascript's window.open() function.

推荐答案

if (window.top != window.self)
 {
}

这篇关于如何检查您的文档是否在IFrame中打开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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