I'm having some trouble with my frames...
I have one frameset inside of another so that I have a banner across
the top and then a menu on the left and content on the right. It looks
like this:
<frameset rows="147,*" cols="*" id="topFrameSet">
<frame id="bannerFrame" name="bannerFrame" scrolling="no" noresize
target="contents" src="banner.htm">
<frameset id="contentFrameSet" cols="222,*">
<frame id="contentsFrame" name="contents" target="main"
src="menu.htm" scrolling="auto">
<frame id="mainFrame" name="main" src="intro.htm"
scrolling="auto">
</frameset>
</frameset>
When someone selects something from the menu frame a new document is
displayed in the content frame. I have a button on my banner frame src
to open up the content in the content frame in a separate window. My
problem is that I can't get the path to the content. If I try this (in
my top level source document):
contentHref = document.getElementById("mainFrame").src
I do get the ORIGINAL path to the document loaded into the contents
Frame. It is like this command is parsing the original HTML that was
loaded. The problem is that content path has changed whenever anyone
selects a menu option. I tried this instead:
contentHref = document.getElementById("mainFrame").location.href
And it always comes up 'null'. I tried:
contentHref = document.getElementById("mainFrame").DOCUMENT.location.href
I was hoping that by referencing the document of the frame that I'd
get the document WITHIN that frame. I did not. I got the top level
document where I define this frame.
Clearly I'm doing something wrong here. In general, I've had many
weird problems when I use a frameset within a frameset. I'd love to
know what is going wrong above, but I'd also love suggestions for
handling pages like this without a double frameset. iframes might be
the way to go. Does Netscape fully support iframes? Also, I'm using
the getElementById function above, because I could not navigate my way
down to the frame I wanted via something like this:
document.topFrameSet.contentFrameSet.mainFrame
I guess this only works for name attributes and not id attributes and
framesets don't have name attributes, do they?
By the way, I'm testing this inside of IE 6.0.
Thanks for any help,
Bill
This is the correct value of the src attribute of the "mainFrame" frame
element - if you hit shift reload, intro.htm will be reloaded in
"mainFrame".
> It is like this command is parsing the original HTML that was
> loaded. The problem is that content path has changed whenever anyone
> selects a menu option. I tried this instead:
>
> contentHref = document.getElementById("mainFrame").location.href
>
> And it always comes up 'null'.
document.getElementById("mainFrame") returns an element node for the
<frame id="mainFrame"> tag, with properties like nodeType (1), tagName
(FRAME) and the usual DOM node properties like parentNode, firstChild,
lastChild etc.
Experimentally (in Mozilla) this is NOT a window object, nor is the
frame Window inserted as a child Node of the frame element (sufficient
reason is that window objects are not elements and do not support the
node interface).
> I tried:
>
> contentHref = document.getElementById("mainFrame").DOCUMENT.location.href
>
> I was hoping that by referencing the document of the frame that I'd
> get the document WITHIN that frame. I did not. I got the top level
> document where I define this frame.
This is likely because IE supports .document as an alternative to the
DOM .ownerDocument property for legacy reasons (IE5 supports .document
but not .ownerDocument).
However .ownerDocument is a standard node property, and being able to
access "mainFrame" element through getElementById of the top document
implies that the top document must be the owner (catch 22). The result
is predictable with the acceptability of .document instead of
.ownerDocument peculiar to IE.
>
> Clearly I'm doing something wrong here. In general, I've had many
> weird problems when I use a frameset within a frameset. I'd love to
> know what is going wrong above,
I would deal with nested framesets using the frames array. In the top
frameset the array contains all the frame windows within the entire
document and may be accessed by frame name attribute (as opposed to id
value).
top.frames.main.location.href
should contain the current href for "mainFrame", and
top.frames.main.parent
should refer to the unnamed frameset containing "contentsFrame" and
"mainFrame". (Framesets do not get placed in the frames array).
I leave for others to comment on iframes which are not something I use.
but I'd also love suggestions for
> handling pages like this without a double frameset. iframes might be
> the way to go. Does Netscape fully support iframes? Also, I'm using
> the getElementById function above, because I could not navigate my way
> down to the frame I wanted via something like this:
>
> document.topFrameSet.contentFrameSet.mainFrame
>
> I guess this only works for name attributes and not id attributes and
> framesets don't have name attributes, do they?
>
> By the way, I'm testing this inside of IE 6.0.
>
> Thanks for any help,
> Bill
You're welcome,
Dom