469,646 Members | 1,298 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,646 developers. It's quick & easy.

Disable Button Enter

Hi

I have a log out button at the top of my site. It is contained within a
web control within the master page.

Because it is the first button on the page, then by default it is the
one that is clicked whenever enter is pressed. This can be extremely
annoying to our users.

Is there any way of disabling this button to the enter press?

I understand that it is possible to set the default button within the
form tag. However this is contained within the master page, and I do
not want to have to set a default button programmatically on every
page.

Hope you can help.

James

Dec 7 '06 #1
1 3037
Hi,

Webmills wrote:
Hi

I have a log out button at the top of my site. It is contained within a
web control within the master page.

Because it is the first button on the page, then by default it is the
one that is clicked whenever enter is pressed. This can be extremely
annoying to our users.

Is there any way of disabling this button to the enter press?

I understand that it is possible to set the default button within the
form tag. However this is contained within the master page, and I do
not want to have to set a default button programmatically on every
page.

Hope you can help.

James
JavaScript can help:

<input type="button"
onfocus="document.getElementById('anotherButton'). focus();" />

Note however that this will prevent the button to get any keyboard
action (like, when you tab through all the controls).

Another way is to use the body onload event to set the focus to another
control:

<body onload="document.getElementById('anotherButton').f ocus();">

This way, the button is only deselected when the page is loaded, but it
can anyway get focus through the keyboard.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Dec 7 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by http://links.i6networks.com | last post: by
3 posts views Thread by sonu | last post: by
2 posts views Thread by cw | last post: by
2 posts views Thread by nicholas | last post: by
1 post views Thread by John Smith | last post: by
16 posts views Thread by Barry Gilmore | last post: by
8 posts views Thread by GS | last post: by
8 posts views Thread by alamodgal | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.