/    Sign up×
Community /Pin to ProfileBookmark

Is jumping to a anker (i.e. link with ID) programmatically with javascript possible?

[URL=http://www.webmasterworld.com/forum91/4935.htm]On another thread (on another forum) [/URL] 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. 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

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@CrazyMerlinFeb 02.2006 — if you mean can you make the page jump to an anchor visually, then yes you can using IE DOM, but not sure using standard DOM.

in IE DOM, there is an element method called scrollIntoView().

Not sure what you mean by your second question, but if you mean can you let someone use 'Enter' instead of 'Tab' to navigate through elements, then yes also.

For non-IE you can trap the 'event' and use 'event.which' to tell you what keycode was pressed. Enter is 13 I believe. You can then have a script that gets the id of the current element, then loops through the elements until it finds it and then moves on 1.

Both your problems work in one kind of browser, it's finding a cross-browser solution that's the tricky thing.
×

Success!

Help @MarcMiller spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...