Created
October 14, 2019 19:35
-
-
Save matheusmurta/a9ba4e48c59dcb8273ec8df473a87ec6 to your computer and use it in GitHub Desktop.
Check if actual window is a iframe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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