jumping to an achor

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

    #1

    jumping to an achor

    is there any way to jump to an anchor on the page load. the thing is I
    dont want to reload the page (as the page is being called by a submit
    button on a form, so if i call the page again with an anchor tag i
    loose all the form details)


    someone said that to jump to an anchor with name anchorID you could
    use

    document.getEle mentbyID("ancho rID").click();

    but this method doesnt exist for anchor objects. is there another way
    (that works) to do this. ive looked at the anchor object inthe
    documentation but dont find any associated methods.

    thanks

    Niall
  • Philip Ronan

    #2
    Re: jumping to an achor

    On 31/8/04 6:13 pm, Niall Linden wrote:
    [color=blue]
    > is there any way to jump to an anchor on the page load.[/color]

    Would it be too much trouble just to add "#anchor" to the URL?

    --
    Philip Ronan
    phil.ronanzzz@v irgin.net
    (Please remove the "z"s if replying by email)


    Comment

    • Grant Wagner

      #3
      Re: jumping to an achor

      Niall Linden wrote:
      [color=blue]
      > is there any way to jump to an anchor on the page load. the thing is I
      > dont want to reload the page (as the page is being called by a submit
      > button on a form, so if i call the page again with an anchor tag i
      > loose all the form details)
      >
      > someone said that to jump to an anchor with name anchorID you could
      > use
      >
      > document.getEle mentbyID("ancho rID").click();
      >
      > but this method doesnt exist for anchor objects. is there another way
      > (that works) to do this. ive looked at the anchor object inthe
      > documentation but dont find any associated methods.
      >
      > thanks
      >
      > Niall[/color]

      if (document.layer s) {
      // netscape 4 support
      location.replac e(location.href + '#anchorname');
      } else {
      location.hash = '#anchorname';
      }

      <a name="anchornam e"></a>

      Be aware, there are browsers other then Netscape 4 that support
      document.layers , this solution works for me because I don't have to worry
      about my userbase using those other browsers. Also, I've discovered some
      odd behaviours with this and Opera 7.54. If I set location.hash twice in a
      row to the same value, it reloads the page. I haven't tracked down if this
      is a problem with my code, or a bug in Opera.

      --
      Grant Wagner <gwagner@agrico reunited.com>
      comp.lang.javas cript FAQ - http://jibbering.com/faq

      Comment

      Working...