jumping to an achor

N

Niall Linden

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.getElementbyID("anchorID").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
 
G

Grant Wagner

Niall said:
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.getElementbyID("anchorID").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

if (document.layers) {
// netscape 4 support
location.replace(location.href + '#anchorname');
} else {
location.hash = '#anchorname';
}

<a name="anchorname"></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.
 

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

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top