Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > complete path to top frame

Reply
Thread Tools

complete path to top frame

 
 
Cactus
Guest
Posts: n/a
 
      11-10-2003
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
 
Reply With Quote
 
 
 
 
Lasse Reichstein Nielsen
Guest
Posts: n/a
 
      11-10-2003
http://www.velocityreviews.com/forums/(E-Mail Removed) (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 - (E-Mail Removed)
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
 
Reply With Quote
 
 
 
 
Disco
Guest
Posts: n/a
 
      11-10-2003
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!


 
Reply With Quote
 
Cactus
Guest
Posts: n/a
 
      11-11-2003
Lasse Reichstein Nielsen <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> (E-Mail Removed) (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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Top lenses versus top telescopes for telephoto work Rich Digital Photography 10 12-29-2006 12:30 AM
How do we know the memory arrangement using in microprocessors? Top-Bottom or Bottom-Top? Cuthbert C Programming 8 09-13-2006 12:09 PM
VoIPCheap/Stunt/SIPDiscount/Et.al - Mobile - Top-up Expiry Period -- Campaign for Correct Expiry Period on Finarea VOIP Service Mobile Top-Ups News Reader UK VOIP 16 06-26-2006 05:03 PM
Top-Up Methods - Finarea (Voipcheap, internetcalls, etc.) et. al., VOIP Services Question - Top-up Methods News Reader UK VOIP 0 04-10-2006 02:41 PM
Why does my Top DashBoard Image do not touch top of the screen? Frederic HOUDE HTML 4 08-30-2004 11:22 PM



Advertisments