[thelist] breaking out of someone else's frameset

Peter-Paul Koch ppk at xs4all.nl
Fri, 03 Dec 1999 16:33:25


>please don't ask me to explain relative merits of one method over another
>wouldn't mind hearing from a more skilled javascripter, though...

Hmmm...interesting collection. I'll take up the challenge and annotate the
methods <grin>.

>if (window != window.top)  top.location.href = location.href;
>if (location.href != top.location.href)  location.href = "index.html"

The safe classical methods.

>if (window != top)  top.location.replace(document.location.href)

'document.location.href' gives trouble in IE3, so it's best to use
'location.href' without the 'document.' bit. The replace is a nice idea,
though.

When using replace you write the new page over the old one in the history
of the browser, while location.href merely adds a page to the history of
the browser.

>if (self != top) top.location = self.location

'location' is not enough for (I think) IE3 again, use 'location.href'

>if (self.parent.frames.length != 0) self.parent.location=document.location;
>if (self.parent.frames.length != 0)  self.parent.location="index.html";

All 'self.' can be deleted, but otherwise these ones are OK too, except
that 'document.location' should read 'location.href'

>if (parent.frame.length !=0) { window.open(self.location); window.stop(); }

With this one you open a pop-up with your site and stop loading the other
site. I recommend against this one, too complicated.

ppk