Forum Moderators: open

Message Too Old, No Replies

Is jumping to an anchor (i.e. link with ID) programmatically Possible?

         

MarcMiller

6:52 am on Feb 2, 2006 (gmt 0)

10+ Year Member



On another thread I asked a question that was perhaps too hard or was not thought out well. I still wouldn't mind to get it answer to it. [webmasterworld.com ] However if you could just tell me how to jump to a link programmatically with javascript that was solved when I am trying to do? I mean I want to jump to a spot on the page (or anchor) with javascript. If this is possible can you tell me where I can find more information on how to do this or just tell me here. A question of less importance, because I can probably figure it out, is pressing the enter key when Tad navigating the equivalent of clicking as far as the event handler onclick is concerned? I know there are other event handlers that will be invoked at that instance but I was just wondering.

Sorry for being a newbie, but would really appreciate some help.
Thanks Marc

kaled

12:07 pm on Feb 2, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



document.location.href = '#anchorname';

OR - to avoid updating history (used by Back button)

document.location.replace('#anchorname');

I've never used replace with anchors but it should be ok.

Kaled.

Bernard Marx

11:46 pm on Feb 2, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In modern browsers, you should be able to "jump" to any id'd element in the way kaled shows above.
- Is that what you were after though?

is pressing the enter key when Tad navigating the equivalent of clicking as far as the event handler onclick is concerned?

It certainly seems like it.

Can this equivalence be guaranteed across all browsers?

Hmmm.

DrDoc

5:43 am on Feb 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can also do something like:

<a href="" id="blah">link text</a>

document.getElementById('blah').click()

Rambo Tribble

1:55 pm on Feb 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Mr. Marx: "Can this equivalence be guaranteed across all browsers?"

I believe it is a standardized accessibility feature.