Reputation: 2841
I find my self in a javascript function as a result of a onload clause in the body of a page. How do I determine the name of the frame I am in? I don't know the id.
Upvotes: 1
Views: 5026
Reputation: 14526
It's been a long time since I've worked with framesets, but I think what you need is loop through the frames in the parent document until you find that the frame is the same as the document's this
global object. Once you know this, just get the id of the tag normally. One way of doing this is:
for (var i = 0; i < parent.frames.length; i++) {
if (parent.frames[i] === this) {
alert(parent.frames[i].id)
}
}
Upvotes: 2