I'd like to know how I can determine if I can take the information I have when I find a frame in the frames array and reverse lookup to find out which iframe that is.
When I debug through the frames loop and look at the properties returned by document.frames[x] it's nothing at all like the properties returned by a loop through getElementsByTagName('iframe').item(x).
So suppose I have an undetermined number of iframes on a page, and an undetermined number of frames. I already have a way of knowing that a particular frame in the loop is my iframe (explained later) but I can't work out which iframe that is. I need to know which iframe it is so I can get its offsetLeft and offsetTop properties. A frame reference returned by the frames array doesn't offer that information.
I need to find the offsetLeft and offsetTop positions of an iframe on a page so I can write a layer to that page in a position relative to the iframe. The iframe has no ID tag (and I have no way of ensuring it has one) or if it does, I don't know what it is. This iframe that I'm looking for is my pages great great grandparent (4 layers of nested iframes where the top and bottom iframes are in the same domain). So the great grandchild iframe has all rights to read/write in the great grandparent iframe. There's no problems there. The problem is finding out where my great grandparent is on the page so I can write next to it.
What I can already determine though is which element in the frames array is my iframe. I do this by getting a reference to it in the great grandchild iframe by doing "var grandparent=parent.parent". That gives me a 'reference' to the iframe that I'm trying to find on the great grandparent page. Now if I loop looking at parent.parent.parent.frames[x] and compare that reference with the 'grandparent' variable reference I find a match in the loop. The references are both to the same object so they match.
So now I know which element in the frames array of the great grandparent is my grandparent. Now if I could just ask it then what its offsetLeft or offsetTop are I'd be all set, but it's a frame at this point, not an iframe, because it's in the frames array, and a frame doesn't have those properties. What I'd need to do somehow is cast the reference to the frame to be a reference to an iframe and I'd get all of its properties. Alternately, find a way of determining which of the iframes corresponds to that frames array entry. Then I could access that iframe directly using getElementById (or something) and then I find the offsets.
When I look at the frames reference object it has very few properties. It has undefined location.href and if I try to overwrite it's 'name' and then look in the iframes array to find that name I have no luck.
So how can I take this found frame and reverse engineer the knowledge to find out which iframe "item" number it is from the getElementsByTag('iframe') loop? Because once I find it via an iframe loop also, I can ask it for its offset values.