How can I tell from a page within an iframe, if the parent itself is also within an iframe?
Explanation:
My home page home.html
contains an iframe
<iframe src="sample.html"></iframe>
I need to detect if home.html
(ie: parent of sample.html
) is within an iframe.
Code in sample.html
:
if(self==window)
{
alert('home.html is not in iframe');
}
else
{
alert('home.html is in iframe');
}
My question is not a duplicate. It's a different case.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…