Mike D
Mike D

Reputation: 2841

how to retrieve frame name

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

Answers (1)

Andrew
Andrew

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

Related Questions