complete path to top frame

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Cactus

    #1

    complete path to top frame

    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.Fram e2.Frame3.Frame 4.Frame5 when the focus is on Frame5?

    Hope someone knows the answer, thanks in advance

    Le Cactus
  • Lasse Reichstein Nielsen

    #2
    Re: complete path to top frame

    le_cactus@msn.c om (Cactus) writes:
    [color=blue]
    > 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.[/color]

    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.
    [color=blue]
    > In other ways, how do I know that I'm in
    > Top.Frame1.Fram e2.Frame3.Frame 4.Frame5 when the focus is on Frame5?[/color]

    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(curren tFrame) {
    var path = "";
    while (currentFrame != top) {
    path = "."+currentFram e.name+path;
    currentFrame = currentFrame.pa rent;
    }
    return "top"+path;
    }

    Then you can put this in each frame:

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

    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    • Disco

      #3
      Re: complete path to top frame

      Cactus wrote:[color=blue]
      > 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.
      >
      > -------------------------------------------[color=green]
      >> Top
      >> ----------------------------------------
      >> | Frame1
      >> | -------------------------------------
      >> | | Frame2
      >> | | ----------------------------------
      >> | | | Frame3
      >> | | | -------------------------------
      >> | | | | Frame4
      >> | | | | ----------------------------
      >> | | | | | Frame5
      >> | | | | |[/color]
      >
      > In other ways, how do I know that I'm in
      > Top.Frame1.Fram e2.Frame3.Frame 4.Frame5 when the focus is on Frame5?
      >
      > Hope someone knows the answer, thanks in advance
      >
      > Le Cactus[/color]

      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.Fram e2.Frame3.Frame 4.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.Fram e5....
      instead you would have smoething like Top.Frame1.Fram e1.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!


      Comment

      • Cactus

        #4
        Re: complete path to top frame

        Lasse Reichstein Nielsen <lrn@hotpop.com > wrote in message news:<7k2797e8. fsf@hotpop.com> ...[color=blue]
        > le_cactus@msn.c om (Cactus) writes:
        >[color=green]
        > > 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.[/color]
        >
        > 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.[/color]
        Bummer.[color=blue]
        >
        > I can't see what the hidden input fields should do.[/color]

        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.
        [color=blue][color=green]
        > > In other ways, how do I know that I'm in
        > > Top.Frame1.Fram e2.Frame3.Frame 4.Frame5 when the focus is on Frame5?[/color]
        >
        > 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(curren tFrame) {
        > var path = "";
        > while (currentFrame != top) {
        > path = "."+currentFram e.name+path;
        > currentFrame = currentFrame.pa rent;
        > }
        > return "top"+path;
        > }[/color]
        Hmmm, thanks. That might also be a way to go about it. Thanks.
        [color=blue]
        >
        > Then you can put this in each frame:
        >
        > <script type="text/javascript">
        > self.onfocus = function() {
        > top.currentFram ePath = top.findPath(se lf);
        > }
        > </script>
        >
        > /L[/color]

        Thanks for the input.

        Cheers,
        Catci

        Comment

        Working...