S
Stevo
If I have an iframe in a HTML page (no framesets involved), then that
iframe will be in the frames array. Code inside that iframe can easily
find out which index in that array it is by doing something like this:
for(var i=0;i<parent.frames.length;i++)
if(window==parent.frames)
alert("Found myself, index="+i);
The problem I'm having lies in what I can then do with knowing that
information. I can't find the position of that iframe. There's no
offsetLeft to look at. It's an array of window objects and that's all
there is to it. Its purpose is to allow you to script the frame, not to
find out where it is visually. So what I need to do is find the iframe
element. I'm finding though that the Mozilla family have the iframes in
the frames array in a different order to those returned by the
getElementsByTagName('iframe') call. IE keeps them in the same order.
So on Firefox for example:
parent.frames
is not equal to
parent.document.getElementsByTagName('iframe').item(i)
The frames array returns window objects and the getElementsByTagName
naturally returns an array of HTMLIframeElements.
How can I determine which iframe from getElementsByTagName is the same
frame I found in the frames array? They don't seem to have any common
properties at all. I don't know the id of the iframe in advance so I
can't use that in a getElementById call either.
With the window object I can look at frames.body.innerHTML and find
out anything I want about that iframe. With the getElementsByTagName I
can only find out properties of the iframe tag (.id, .width, .height etc).
At the moment I'm thinking that if I want a window handle, then I use
the frames array. If I want an object that I can find the position of,
then all I have to go on is the width and height (which I do know), but
if there are multiple iframes with the same width/height combination
then I could be matching the wrong one.
iframe will be in the frames array. Code inside that iframe can easily
find out which index in that array it is by doing something like this:
for(var i=0;i<parent.frames.length;i++)
if(window==parent.frames)
alert("Found myself, index="+i);
The problem I'm having lies in what I can then do with knowing that
information. I can't find the position of that iframe. There's no
offsetLeft to look at. It's an array of window objects and that's all
there is to it. Its purpose is to allow you to script the frame, not to
find out where it is visually. So what I need to do is find the iframe
element. I'm finding though that the Mozilla family have the iframes in
the frames array in a different order to those returned by the
getElementsByTagName('iframe') call. IE keeps them in the same order.
So on Firefox for example:
parent.frames
is not equal to
parent.document.getElementsByTagName('iframe').item(i)
The frames array returns window objects and the getElementsByTagName
naturally returns an array of HTMLIframeElements.
How can I determine which iframe from getElementsByTagName is the same
frame I found in the frames array? They don't seem to have any common
properties at all. I don't know the id of the iframe in advance so I
can't use that in a getElementById call either.
With the window object I can look at frames.body.innerHTML and find
out anything I want about that iframe. With the getElementsByTagName I
can only find out properties of the iframe tag (.id, .width, .height etc).
At the moment I'm thinking that if I want a window handle, then I use
the frames array. If I want an object that I can find the position of,
then all I have to go on is the width and height (which I do know), but
if there are multiple iframes with the same width/height combination
then I could be matching the wrong one.