If you wish to check if there is any iframe at all, you could use getElementsByTagName('iframe'). To make live a little easier, you can take a look at jQuery. This is a Javascript library that helps you to create DOM objects and/or find them in the DOM tree.
The X-Frame-Options HTTP response header can be used to indicate whether or not a browser should be allowed to render a page in a <frame> , <iframe> or <object> . Sites can use this to avoid clickjacking attacks, by ensuring that their content is not embedded into other sites.
window. close(); or this: top. window. close(); you should be able to close it.
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";
var isInIFrame = (window.location != window.parent.location);
if(isInIFrame==true){
// iframe
}
else {
// no iframe
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With