By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,747 Members | 1,759 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,747 IT Pros & Developers. It's quick & easy.

complete path to top frame

P: n/a
Hi,

I have a tree like structure build with javascrtip and loads of
iframes. How can find the complete 'frame-path' to the frame that
focused? I'm sure I can contruct something with hidden input field so
I can do a loop till I'm at the top frame, but there might be a much
simpler way.

-------------------------------------------
| Top
| ----------------------------------------
| | Frame1
| | -------------------------------------
| | | Frame2
| | | ----------------------------------
| | | | Frame3
| | | | -------------------------------
| | | | | Frame4
| | | | | ----------------------------
| | | | | | Frame5
| | | | | |

In other ways, how do I know that I'm in
Top.Frame1.Frame2.Frame3.Frame4.Frame5 when the focus is on Frame5?

Hope someone knows the answer, thanks in advance

Le Cactus
Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
le*******@msn.com (Cactus) writes:
I have a tree like structure build with javascrtip and loads of
iframes. How can find the complete 'frame-path' to the frame that
focused? I'm sure I can contruct something with hidden input field so
I can do a loop till I'm at the top frame, but there might be a much
simpler way.
I don't think so. The pages in the frames are independent of each
other, they don't need to know where they are in the frame structure.

I can't see what the hidden input fields should do.
In other ways, how do I know that I'm in
Top.Frame1.Frame2.Frame3.Frame4.Frame5 when the focus is on Frame5?


How do you know that the focus is in frame 5? That is the hard part.

You can probably do that with onfocus-handlers on the frame objects.

Assuming that you have a reference to the focused frame, currentFrame,
then you can use the parent property to find the surrounding frame:

function findPath(currentFrame) {
var path = "";
while (currentFrame != top) {
path = "."+currentFrame.name+path;
currentFrame = currentFrame.parent;
}
return "top"+path;
}

Then you can put this in each frame:

<script type="text/javascript">
self.onfocus = function() {
top.currentFramePath = top.findPath(self);
}
</script>

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

P: n/a
Cactus wrote:
Hi,

I have a tree like structure build with javascrtip and loads of
iframes. How can find the complete 'frame-path' to the frame that
focused? I'm sure I can contruct something with hidden input field so
I can do a loop till I'm at the top frame, but there might be a much
simpler way.

-------------------------------------------
Top
----------------------------------------
| Frame1
| -------------------------------------
| | Frame2
| | ----------------------------------
| | | Frame3
| | | -------------------------------
| | | | Frame4
| | | | ----------------------------
| | | | | Frame5
| | | | |


In other ways, how do I know that I'm in
Top.Frame1.Frame2.Frame3.Frame4.Frame5 when the focus is on Frame5?

Hope someone knows the answer, thanks in advance

Le Cactus


Maybe a different way to think of what you are trying to accomplish (I am
not exactly sure) would be to ensure the uniqueness of the frame names.
IE. Wouldnt you assume that Top.Frame1.Frame2.Frame3.Frame4.Frame5 will
definatly be Frame5 just because of the unique name of the frame?

I can not see why you would have something like Top.Frame1.Frame5....
instead you would have smoething like Top.Frame1.Frame1.5 or do smoething
like this....
Top.F1.F1_1.F1_1_1.F1_1_1_1
Top.F1.F1_2.F1_2_1.F1_2_1_1
Top.F1.F1_2.F1_2_2.F1_2_2_1
Top.F1.F1_2.F1_2_1.F1_2_2_2
This may or may not be any use to you. It was not use to me!
Jul 20 '05 #3

P: n/a
Lasse Reichstein Nielsen <lr*@hotpop.com> wrote in message news:<7k**********@hotpop.com>...
le*******@msn.com (Cactus) writes:
I have a tree like structure build with javascrtip and loads of
iframes. How can find the complete 'frame-path' to the frame that
focused? I'm sure I can contruct something with hidden input field so
I can do a loop till I'm at the top frame, but there might be a much
simpler way.
I don't think so. The pages in the frames are independent of each
other, they don't need to know where they are in the frame structure.

Bummer.
I can't see what the hidden input fields should do.
My idea was to put a hidden input field in earch frame. On frameload I
could fill the field with that field value of the parrent frame and
the current frame name. That way I would always know (in a frame)
where I am.
By calling a function in a frame witch returns me to the top frame, I
could then use that value (after transfering it to another hidden
field on the top frame) from where it was called.
In other ways, how do I know that I'm in
Top.Frame1.Frame2.Frame3.Frame4.Frame5 when the focus is on Frame5?


How do you know that the focus is in frame 5? That is the hard part.

You can probably do that with onfocus-handlers on the frame objects.

Assuming that you have a reference to the focused frame, currentFrame,
then you can use the parent property to find the surrounding frame:

function findPath(currentFrame) {
var path = "";
while (currentFrame != top) {
path = "."+currentFrame.name+path;
currentFrame = currentFrame.parent;
}
return "top"+path;
}

Hmmm, thanks. That might also be a way to go about it. Thanks.

Then you can put this in each frame:

<script type="text/javascript">
self.onfocus = function() {
top.currentFramePath = top.findPath(self);
}
</script>

/L


Thanks for the input.

Cheers,
Catci
Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.