anchors

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

    anchors

    Hi,

    I have a topframe and a mainframe.

    The topframe contains a listbox with trucknumbers (non sequential).
    The mainframe contains a page, where each truck has a table with data.
    In the topleft cell of each table I put a named link <a name=$trucknumb er>.
    Tables are generated using php.

    I want to use an onChange event in the listbox to jump to the corresponding
    anchor in the mainframe. The function below doesn't work.

    function jump(anker){
    parent.frames['main'].href="#"+paren t.frames['main'].links[anker].value;
    }

    any suggestions ?


    thx

    Ward
  • Ivo

    #2
    Re: anchors

    "Ward" <king.albert.II @for.president. com> wrote in message
    news:Xns9499983 60E130wardgermo npreverhels@195 .130.132.70...
    <snip>[color=blue]
    > function jump(anker){
    > parent.frames['main'].href="#"+paren t.frames['main'].links[anker].value;
    > }[/color]

    Have you also tried the variant with "location." just before "href." ?
    HTH
    Ivo
    [color=blue]
    > any suggestions ?
    > thx
    >
    > Ward[/color]


    Comment

    • Lee

      #3
      Re: anchors

      Ward said:[color=blue]
      >
      >Hi,
      >
      >I have a topframe and a mainframe.
      >
      >The topframe contains a listbox with trucknumbers (non sequential).
      >The mainframe contains a page, where each truck has a table with data.
      >In the topleft cell of each table I put a named link <a name=$trucknumb er>.
      >Tables are generated using php.
      >
      >I want to use an onChange event in the listbox to jump to the corresponding
      >anchor in the mainframe. The function below doesn't work.
      >
      >function jump(anker){
      >parent.frame s['main'].href="#"+paren t.frames['main'].links[anker].value;[/color]

      parent.frames['main'].location.hash= "#"+truckNumber ;

      Comment

      • Michael Winter

        #4
        Re: anchors

        On Tue, 24 Feb 2004 13:57:47 GMT, Ward <king.albert.II @for.president. com>
        wrote:
        [color=blue]
        > The topframe contains a listbox with trucknumbers (non sequential).
        > The mainframe contains a page, where each truck has a table with data.
        > In the topleft cell of each table I put a named link
        > <a name=$trucknumb er>.[/color]

        New webpages should target sections within documents using the id
        attribute instead of using A elements as anchors. So, in place of:

        <table>
        <tr>
        <td><a name="frag-identifier"></a>
        ...

        you might use:

        <table>
        <tr id="frag-identifier">
        <td>
        ...
        [color=blue]
        > I want to use an onChange event in the listbox to jump to the
        > corresponding anchor in the mainframe. The function below
        > doesn't work.
        >
        > function jump(anker){
        > parent.frames['main'].href="#"+paren t.frames['main'].links[anker].value;
        > }
        >
        > any suggestions ?[/color]

        1) Window objects, and therefore frames, do not have a href property.
        2) ...nor do they have a links property.
        3) Knowing what 'anker' is would be helpful.

        The approach you have presented seems likely to fail in all browsers. Even
        after correcting the l-value to use location, not href, it will still fail
        in most browsers.

        A simpler solution would be:

        function changePage( linkList ) {
        var fragment = linkList.option s[ linkList.select edValue ].value;

        // Check that the option does contain a fragment identifier
        // This allows for options such as "Choose section" which should
        // have no destination
        if( fragment ) parent.frames['main'].location = '#' + fragment;
        }
        ...
        <select onchange="chang ePage(this)">
        <option value="">Choose section</option>
        <option value="Section-1">Section 1</option>
        <option value="Section-2">Section 2</option>
        ...
        </select>

        Mike

        --
        Michael Winter
        M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

        Comment

        • Ward Germonpé

          #5
          Re: anchors

          Michael Winter <M.Winter@bluey onder.co.invali d> wrote in
          news:opr3vtcz1y 5vklcq@news-text.blueyonder .co.uk:
          [color=blue]
          > On Tue, 24 Feb 2004 13:57:47 GMT, Ward
          > <king.albert.II @for.president. com> wrote:
          >[color=green]
          >> The topframe contains a listbox with trucknumbers (non sequential).
          >> The mainframe contains a page, where each truck has a table with
          >> data. In the topleft cell of each table I put a named link
          >> <a name=$trucknumb er>.[/color]
          >
          > New webpages should target sections within documents using the id
          > attribute instead of using A elements as anchors. So, in place of:
          >
          > <table>
          > <tr>
          > <td><a name="frag-identifier"></a>
          > ...
          >
          > you might use:
          >
          > <table>
          > <tr id="frag-identifier">
          > <td>
          > ...
          >[color=green]
          >> I want to use an onChange event in the listbox to jump to the
          >> corresponding anchor in the mainframe. The function below
          >> doesn't work.
          >>
          >> function jump(anker){
          >> parent.frames['main'].href="#"+paren t.frames['main'].links[anker].valu
          >> e; }
          >>
          >> any suggestions ?[/color]
          >
          > 1) Window objects, and therefore frames, do not have a href property.
          > 2) ...nor do they have a links property.
          > 3) Knowing what 'anker' is would be helpful.
          >
          > The approach you have presented seems likely to fail in all browsers.
          > Even after correcting the l-value to use location, not href, it will
          > still fail in most browsers.
          >
          > A simpler solution would be:
          >
          > function changePage( linkList ) {
          > var fragment = linkList.option s[ linkList.select edValue ].value;
          >
          > // Check that the option does contain a fragment identifier
          > // This allows for options such as "Choose section" which should
          > // have no destination
          > if( fragment ) parent.frames['main'].location = '#' + fragment;
          > }
          > ...
          > <select onchange="chang ePage(this)">
          > <option value="">Choose section</option>
          > <option value="Section-1">Section 1</option>
          > <option value="Section-2">Section 2</option>
          > ...
          > </select>
          >
          > Mike
          >[/color]

          If you change selectedValue to selectedIndex your example does indeed
          work.

          thx for your help

          Ward

          Comment

          • Michael Winter

            #6
            Re: anchors

            On Tue, 24 Feb 2004 21:45:02 GMT, Ward Germonpé
            <kingalbertII@f orpresident.com > wrote:
            [color=blue]
            > Michael Winter <M.Winter@bluey onder.co.invali d> wrote in
            > news:opr3vtcz1y 5vklcq@news-text.blueyonder .co.uk:[/color]

            [snip]
            [color=blue][color=green]
            >> function changePage( linkList ) {
            >> var fragment = linkList.option s[ linkList.select edValue ].value;[/color][/color]

            [snip]
            [color=blue]
            > If you change selectedValue to selectedIndex your example does indeed
            > work.[/color]

            Sorry. :) Lapse in concentration.

            Mike

            --
            Michael Winter
            M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

            Comment

            • Ward

              #7
              Re: anchors

              Michael Winter <M.Winter@bluey onder.co.invali d> wrote in
              news:opr3wdebvj 5vklcq@news-text.blueyonder .co.uk:
              [color=blue]
              > On Tue, 24 Feb 2004 21:45:02 GMT, Ward Germonpé
              ><kingalbertII@ forpresident.co m> wrote:
              >[color=green]
              >> Michael Winter <M.Winter@bluey onder.co.invali d> wrote in
              >> news:opr3vtcz1y 5vklcq@news-text.blueyonder .co.uk:[/color]
              >
              > [snip]
              >[color=green][color=darkred]
              >>> function changePage( linkList ) {
              >>> var fragment = linkList.option s[ linkList.select edValue ].value;[/color][/color]
              >
              > [snip]
              >[color=green]
              >> If you change selectedValue to selectedIndex your example does indeed
              >> work.[/color]
              >
              > Sorry. :) Lapse in concentration.
              >
              > Mike
              >[/color]

              I'm not quite there yet...

              I had to change the code as follows to prevent the topframe from loading
              into the mainframe.

              if (fragment) parent.frames['main'].location = parent.frames
              ['main'].location + '#' + fragment;

              Now it works, but only once.

              There are no errors in the javascript console.


              thx

              Ward


              Comment

              • Michael Winter

                #8
                Re: anchors

                On Wed, 25 Feb 2004 10:18:27 GMT, Ward <king.albert.II @for.president. com>
                wrote:
                [color=blue]
                > Michael Winter <M.Winter@bluey onder.co.invali d> wrote in
                > news:opr3wdebvj 5vklcq@news-text.blueyonder .co.uk:
                >[color=green]
                >> On Tue, 24 Feb 2004 21:45:02 GMT, Ward Germonp
                >> <kingalbertII@f orpresident.com > wrote:[/color][/color]

                [snip]
                [color=blue][color=green][color=darkred]
                >>> If you change selectedValue to selectedIndex your example does indeed
                >>> work.[/color]
                >>
                >> Sorry. :) Lapse in concentration.[/color]
                >
                > I'm not quite there yet...
                >
                > I had to change the code as follows to prevent the topframe from loading
                > into the mainframe.
                >
                > if (fragment) parent.frames['main'].location = parent.frames
                > ['main'].location + '#' + fragment;
                >
                > Now it works, but only once.
                >
                > There are no errors in the javascript console.[/color]

                That is because a second usage will append, not replace, the first
                fragment identifier. That is,

                index.html -> index.html#Sect ion-1 -> index.html#Sect ion-1#Section-2

                Lee's use of Location.hash should fix this:

                if (fragment) parent.frames['main'].location.hash = '#' +
                fragment;

                Hopefully, that should be it.

                Mike

                --
                Michael Winter
                M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

                Comment

                • Ward

                  #9
                  Re: anchors

                  Michael Winter <M.Winter@bluey onder.co.invali d> wrote in
                  news:opr3w9cfo1 5vklcq@news-text.blueyonder .co.uk:
                  [color=blue]
                  > On Wed, 25 Feb 2004 10:18:27 GMT, Ward
                  > <king.albert.II @for.president. com> wrote:
                  >[color=green]
                  >> Michael Winter <M.Winter@bluey onder.co.invali d> wrote in
                  >> news:opr3wdebvj 5vklcq@news-text.blueyonder .co.uk:
                  >>[color=darkred]
                  >>> On Tue, 24 Feb 2004 21:45:02 GMT, Ward Germonp
                  >>> <kingalbertII@f orpresident.com > wrote:[/color][/color]
                  >
                  > [snip]
                  >[color=green][color=darkred]
                  >>>> If you change selectedValue to selectedIndex your example does
                  >>>> indeed work.
                  >>>
                  >>> Sorry. :) Lapse in concentration.[/color]
                  >>
                  >> I'm not quite there yet...
                  >>
                  >> I had to change the code as follows to prevent the topframe from
                  >> loading into the mainframe.
                  >>
                  >> if (fragment) parent.frames['main'].location = parent.frames
                  >> ['main'].location + '#' + fragment;
                  >>
                  >> Now it works, but only once.
                  >>
                  >> There are no errors in the javascript console.[/color]
                  >
                  > That is because a second usage will append, not replace, the first
                  > fragment identifier. That is,
                  >
                  > index.html -> index.html#Sect ion-1 ->
                  > index.html#Sect ion-1#Section-2
                  >
                  > Lee's use of Location.hash should fix this:
                  >
                  > if (fragment) parent.frames['main'].location.hash = '#' +
                  > fragment;
                  >
                  > Hopefully, that should be it.
                  >
                  > Mike
                  >[/color]

                  It works !

                  thx a lot

                  Ward

                  Comment

                  Working...