Created
September 15, 2015 13:52
-
-
Save adamculpepper/9a429bd9ce357b60284f to your computer and use it in GitHub Desktop.
JavaScript/jQuery: Detect if content is inside iframe
This file contains hidden or 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
function detectFrame() { | |
if (window.frameElement) { | |
// in frame | |
alert('framed: YES'); | |
$('body').addClass('framed'); | |
} else { | |
// not in frame | |
alert('framed: NO'); | |
$('body').removeClass('framed'); | |
} | |
} | |
$(window).load(function() { | |
detectFrame(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment