Bustin' Out With Frame Busting by Geoff Blake (posted May 17, 2006)

When working with framesets, it’s a major no-no to link to other web sites and have them appear within your frameset. Some sites do this as a way to try to keep the visitor from leaving their site entirely. With a site appearing within another website, it makes the external site look like it’s a part of the framed site. Sneaky. Don’t forget, the point of frames is to provide navigation for web users, not to control them.

Now, what do you do if you find your own site stuck in someone else’s frames? The best approach is to use JavaScript to detect if your page appears within a frameset. If it does, the code will reload your page into the browser window, replacing the frameset. A wee bit of hand coding is involved to get this to work. If you’re squeamish, don’t worry—it’s actually really easy.

Here’s how to hand code JavaScript to bust out of frames:

  1. In Dreamweaver, open the page that you’d like to add the JavaScript code to.

If you want to make sure that all the pages in your site will bust out of frames, you'll have to add this code to each page. There goes your weekend.

  1. On Dreamweaver’s Document toolbar, click on the Show Code View button.
    This switches you to Dreamweaver’s code view. Or use Dreamweaver's Code Inspector by choosing Window > Code Inspector.
  2. Type in the following code into the <head> area of your page:

<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
if (top != self) top.location.href = location.href;
// -->
</SCRIPT>

  1. Save your page.

Wanna test it out? Try building a quick frameset, then link to your page from your own frameset. Like magic, it’ll bust out. Nifty, huh? So now you know how to break out of other site's frames!

[ Back to Web + Mag Articles ]

 

Search Ten Ton
 
Web tentonbooks.com
Book Titles
Video Training
Mag+Web Articles
Shop Ten Ton
Geoff's Atomik Art
Ten Ton Survey
Industry Leader Interviews
Reader Reviews
About Geoff Blake
Improve Ten Ton
About Ten Ton Books | Book Titles | Video Learning | Web + Mag Articles | Shop Ten Ton | Zap! Bang! Boom! | Advertise with Ten Ton | Site Map | Contact Ten Ton