Skip to content

Instantly share code, notes, and snippets.

@weivall
Created April 25, 2012 14:07
Show Gist options
  • Save weivall/2489960 to your computer and use it in GitHub Desktop.
Save weivall/2489960 to your computer and use it in GitHub Desktop.
Prevent click-jacking
$(document).ready(function() {
// Prevent click-jacking
if (top != self) {
$('body').html('<h1>Unauthorized</h1>')
}
});
//// ============
try {
if ((self.parent && !(self.parent === self)) && (self.parent.frames.length != 0)) {
self.parent.location = document.location;
}
} catch(e) { }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment