jump to an anchor/bookmark

R

Rob

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_three");
}
}

Can this be done and if yes how?

Thanks in advance
Rob
 
Y

Yann-Erwan Perio

Rob said:
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.


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

window.onload=function(evt){
var hashValue="#foo";
if(location.hash!=hashValue)
location.hash=hashValue;
}


HTH
Yep.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top