jump to an anchor/bookmark

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

    jump to an anchor/bookmark

    Hello all,

    I have an anchor in my page like <a name-"phase_two"/>.
    When I load my page I call the function body_onload in the onload event of
    the body tag. Then I like to jump to this anchor/bookmark based on the value
    of an variable.

    pseudecode example:

    function body_onload(){
    if (phase==2){
    jump_to_anchor( "phase_two" );
    }

    if (phase==3){
    jump_to_anchor( "phase_thre e");
    }
    }

    Can this be done and if yes how?

    Thanks in advance
    Rob


  • Yann-Erwan Perio

    #2
    Re: jump to an anchor/bookmark

    Rob wrote:
    [color=blue]
    > I have an anchor in my page like <a name-"phase_two"/>.
    > When I load my page I call the function body_onload in the onload event of
    > the body tag. Then I like to jump to this anchor/bookmark based on the value
    > of an variable.[/color]


    Check the location.hash property:
    <URL:http://msdn.microsoft. com/workshop/author/dhtml/reference/properties/hash.asp>

    window.onload=f unction(evt){
    var hashValue="#foo ";
    if(location.has h!=hashValue)
    location.hash=h ashValue;
    }


    HTH
    Yep.

    Comment

    • Rob

      #3
      Re: jump to an anchor/bookmark

      Thank a lot, exactly what I needed

      Rob
      "Yann-Erwan Perio" <y-e.perio@em-lyon.com> schreef in bericht
      news:410ab977$0 $22940$626a14ce @news.free.fr.. .[color=blue]
      > Rob wrote:
      >[color=green]
      > > I have an anchor in my page like <a name-"phase_two"/>.
      > > When I load my page I call the function body_onload in the onload event[/color][/color]
      of[color=blue][color=green]
      > > the body tag. Then I like to jump to this anchor/bookmark based on the[/color][/color]
      value[color=blue][color=green]
      > > of an variable.[/color]
      >
      >
      > Check the location.hash property:
      >[/color]
      <URL:http://msdn.microsoft.com/workshop/a.../properties/ha
      sh.asp>[color=blue]
      >
      > window.onload=f unction(evt){
      > var hashValue="#foo ";
      > if(location.has h!=hashValue)
      > location.hash=h ashValue;
      > }
      >
      >
      > HTH
      > Yep.[/color]


      Comment

      Working...