Discussion Locked

Enter key for A tag

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
Is there anyway that if i press the ENTER key it should call the onclick Event of the Anchor tag?

5 replies

by cal

Yes, sort of.

In the code below, I've created a sample. It's not foolproof and it will break if you tinker too much with it but it should point you in the right direction.

Cal

*
* Cal Evans
* Professional Nerd Herder
* http://www.calevans.com
*

(!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN")

(html)
(head)
(title)Click Test(/title)
(script language="JavaScript")
function load(){
// gives the button focus
document.all.TestMe.focus();
}
(/script)(/head)

(body onLoad="load();")
(a href="http://www.calevans.com")Test Link(/a)(BR)
(input type="button" name="TestMe" onclick="window.location = document.links[0].href" value="Press Enter")

(/body)
(/html)

This discussion is closed to new replies.