Skip to content

Instantly share code, notes, and snippets.

@adamculpepper
Created September 15, 2015 13:52
Show Gist options
  • Save adamculpepper/9a429bd9ce357b60284f to your computer and use it in GitHub Desktop.
Save adamculpepper/9a429bd9ce357b60284f to your computer and use it in GitHub Desktop.
JavaScript/jQuery: Detect if content is inside iframe
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