最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - HTML select onchange accessibility concerns - Stack Overflow

programmeradmin1浏览0评论

We have a request to use a select element's onchange to trigger a move to a new page.

In the past, web accessibility literature I've read has generally advised against doing this. This was on the grounds that it breaks user expectation, and browsers (particularly IE < 6) fired the change event even when moving through options with the keyboard, making it impossible for keyboard-only users to make a selection.

IE6+ and all other more modern browsers I have tested fire the select onchange when an option is actually selected by mouse or enter key. Analytics for the application in question show that earlier IE browsers are essentially eradicated (< 0.01%)

Given that our users will be able to operate these select elements properly with a keyboard only, should this feature still be considered an impediment to accessibility? This behavior seems so mon nowadays that I wonder also if it really still does break user expectation in a meaningful way?

EDIT: IE behaves differently if the select is focused with the mouse or keyboard. When focused with the mouse, keyboarding through options does not fire onchange but when tabbing to focus it via keyboard, the onchange does fire when arrowing through.

We have a request to use a select element's onchange to trigger a move to a new page.

In the past, web accessibility literature I've read has generally advised against doing this. This was on the grounds that it breaks user expectation, and browsers (particularly IE < 6) fired the change event even when moving through options with the keyboard, making it impossible for keyboard-only users to make a selection.

IE6+ and all other more modern browsers I have tested fire the select onchange when an option is actually selected by mouse or enter key. Analytics for the application in question show that earlier IE browsers are essentially eradicated (< 0.01%)

Given that our users will be able to operate these select elements properly with a keyboard only, should this feature still be considered an impediment to accessibility? This behavior seems so mon nowadays that I wonder also if it really still does break user expectation in a meaningful way?

EDIT: IE behaves differently if the select is focused with the mouse or keyboard. When focused with the mouse, keyboarding through options does not fire onchange but when tabbing to focus it via keyboard, the onchange does fire when arrowing through.

Share Improve this question edited Feb 23, 2011 at 19:35 Michael Berkowski asked Feb 23, 2011 at 18:29 Michael BerkowskiMichael Berkowski 271k47 gold badges450 silver badges393 bronze badges 5
  • 5 Wait a second, did you just imply that IE6 is a modern browser? ;) – Andrew Marshall Commented Feb 23, 2011 at 18:33
  • What exactly are your question about? – devasia2112 Commented Feb 23, 2011 at 18:36
  • @Andrew Marshall After typing that sentence I hoped no one would think that. – Michael Berkowski Commented Feb 23, 2011 at 18:37
  • @Fernando Should the practice of using a select to trigger a move to a new page still be avoided because of accessibility concerns? Is that clearer? – Michael Berkowski Commented Feb 23, 2011 at 18:39
  • Now it is. I think sometimes it is very useful, depends exactly what your needs since it is provided with the most browsers in the market. I use myself it since I had started to programming ... why "be avoided"? give us one good reason to... – devasia2112 Commented Feb 23, 2011 at 18:46
Add a ment  | 

2 Answers 2

Reset to default 7

Using the onchange event of the select element to navigate between pages can definitely pose an accessibility problem for keyboard-only users.

There is at least one method of creating accessible select elements with onchange handlers and it has been on the interwebs since 2004!

Direct link to the Accessible Select code.

I agree with you that this type of functionality is very mon. However, most sites use links instead of a <select> to achieve the effect (if I'm not mistaken). I.E. it's the standard (pun intended).

发布评论

评论列表(0)

  1. 暂无评论