如果父级本身也在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)
我的问题不是重复的.这是一个不同的案例.