JavaScript FrameBuster Snippet
Oftentimes you want to make sure your site isn't being IFRAME'd. Sometimes it's for security reasons, other times it's so your site's content isn't being skimmed else, and other times it's...oh, who cares, you just want to do it. Here's a short way to escape frames:
if (top.location != self.location) {
top.location = self.location.href;
}
Uglify this and you get 63 characters of gold. Simple, effective.
Many of the new APIs provided to us by browser vendors are more targeted toward the mobile user than the desktop user. One of those simple APIs the Vibration API. The Vibration API allows developers to direct the device, using JavaScript, to vibrate in...
CSS animations are a lot of fun; the beauty of them is that through many simple properties, you can create anything from an elegant fade in to a WTF-Pixar-would-be-proud effect. One CSS effect somewhere in between is the CSS flip effect, whereby there's...
It's no secret that Facebook has become a major traffic driver for all types of websites. Nowadays even large corporations steer consumers toward their Facebook pages instead of the corporate websites directly. And of course there are Facebook "Like" and "Recommend" widgets on every website. One...
Sorry bit of a jacascript noob here – this sounds great but how would one implement it? Where does it go?
Again apologies for what must sound a simple question.
Just toss it at the top of your javascript file :). Really anywhere in your JS this would work.
Just don’t put it inside a function unless that your intention. For example if for some reason you want to give your users a chance to make sure the page isn’t iframed by clicking a button then you put that code in a function say unIFrameMe() and then call that function when onclick the button.
In general, you’ll want this code to be outside of a function, so it is run when the js is loaded.
EMILIO!
But what about the Frame Buster Buster?
http://stackoverflow.com/questions/958997/frame-buster-buster-buster-code-needed
Thanks for the answers re the javascript.
htaccess solutions might be better as they are not so easily bypassed:
To blocks all sites (including your own) from iframing your pages:
or to block any external site from iframing your pages:
You can also only block some of your urls with the x-frame-options header. Here’s an apache solution
Header always append
X-Frame-Options SAMEORIGIN
# Block any site from applying an iframe.Apparently I didn’t use `pre` tags.