[Javascript] How to reference a frame object from within a frameset, using J

Peter-Paul Koch gassinaumasis at hotmail.com
Thu Apr 26 02:40:32 CDT 2001


>a user goes from a non-frameset page to a frameset page.  In that
>frameset document, I want to use Javascript to determine what pages will go 
>in each frame (based on some variables I gather from the first page using 
>cookies).

Cookies aren't necessary, see 
http://www.xs4all.nl/~ppk/js/index.html?framecustom.html for my solution to 
this problem.


>onLoad=
>  window.top.main_frame.location="mainpage.html";
>  window.top.exit.location="exit.html";
>  window.top.photonav.location="nav.html";

The top isn't necessary here (though it shouldn't hurt either). I presume 
the onLoad is on the first FRAMESET tag?

>The following attempts don't work either:
>  parent.main_frame.location="mainpage.html"
>  self.main_frame.location="mainpage.html"
>  self.frames[0].location="mainpage.html"

The parent one wouldn't work since the frameset has no parent.

>Any clues as to how to do this?
>It doesn't matter where I put my Javascript function.
>IE gives me an error message  like: "self.frames[0] is not an
>object...."
>Perhaps I just can't access the frame objects from within the frameset 
>document itself, in IE.

Hmmm...can't remember. Anyway, the frameset must be completely loaded first 
(and maybe in IE5Mac that includes the pages in the frames). I'm certain 
that I've done it once, but I can't remember the details.

Anyway, for what you want (non-frameset page that leads to several pages all 
inside the same frameset, right?) try my script. It's much easier.

ppk

_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.





More information about the Javascript mailing list