相关疑难解决方法(0)

如何识别网页是在iframe中加载还是直接加载到浏览器窗口?

我正在写一个基于iframe的Facebook应用程序.现在我想使用相同的html页面来呈现普通网站以及facebook中的画布页面.我想知道我是否可以确定页面是在iframe中加载还是直接在浏览器中加载?

javascript iframe facebook

554
推荐指数
7
解决办法
30万
查看次数

检查父窗口是否为iframe

如果父级本身也在iframe中,我如何从iframe中的页面判断?

说明:

我的主页home.html包含iframe

<iframe src="sample.html"></iframe>
Run Code Online (Sandbox Code Playgroud)

我需要检测if home.html(即:parent sample.html)是否在iframe中.

代码sample.html:

if(self==window)
{
    alert('home.html is not in iframe');
}
else
{
    alert('home.html is in iframe');
}
Run Code Online (Sandbox Code Playgroud)

我的问题不是重复的.这是一个不同的案例.

javascript iframe jquery

51
推荐指数
3
解决办法
9万
查看次数

标签 统计

iframe ×2

javascript ×2

facebook ×1

jquery ×1