Breaks out of frames on a page. Very useful for when your site(s) have had their content framed by other sites and you want to have your site given it's proper attention.
<script language="javascript" type="text/javascript"> /* ====================================================== * ': This forces the current document to the top of any ': frames. ': You MUST either remove it or comment it out if you ': want the page to be frameable in browsers supporting ': scripting. '* ====================================================== */ if (top.location != self.location) { top.location.replace(self.location); // pop to top } </script>
Basically, all this does is find out if the parent frame has the same URL as the current frame, and sets the parent frame's url to this frame if not.
This code will also prevent you from framing your own pages, so, uh, it's not always what you may want to do on your page(s). There is a better solution however, check out the Super-Break-Out and/or the Pseudo-Break-Out scripts.
Caveats:
As always, client-side script requires that the client support script in order for it to work at all. Though it is rare these days that a browser will not support script, it may be disabled or limited due to security concerns. As long as scripting is available on the client this script should function correctly without errors.
As stated before, this script will also prevent you from framing your own site! If you need to frame your own site there are other options, like Super-Break-Out and Pseudo-Break-Out.