Skip to content

Instantly share code, notes, and snippets.

@matheusmurta
Created October 14, 2019 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matheusmurta/a9ba4e48c59dcb8273ec8df473a87ec6 to your computer and use it in GitHub Desktop.
Save matheusmurta/a9ba4e48c59dcb8273ec8df473a87ec6 to your computer and use it in GitHub Desktop.
Check if actual window is a iframe
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){
console.log('window is a frame/iframe')
}
function inIframe () {
try {
return window.self !== window.top;
} catch (e) {
return true;
}
}
function iniFrame() {
if ( window.location !== window.parent.location )
{
// The page is in an iFrames
document.write("The page is in an iFrame");
}
else {
// The page is not in an iFrame
document.write("The page is not in an iFrame");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment