How can I tell from a page within an iframe, if the parent itself is also within an iframe?
Explanation:
My home page home.ht
var isInIFrame = (window.location != window.parent.location);
if(isInIFrame==true){
// iframe
}
else {
// no iframe
}
This is true if a window is not a frame/iframe:
if(self==top)
If you like to see if the parent window of the given window is a frame, use:
if(parent==top)
It's a simple comparision of top
(the most top window of the window hierarchy) and another window object (self
or parent
).
Check if window.frameElement
is not null and see if its nodeName property is "IFRAME":
var isInIframe = window.frameElement && window.frameElement.nodeName == "IFRAME";