简体   繁体   English

HTML选择onchange可访问性问题

[英]HTML select onchange accessibility concerns

We have a request to use a select element's onchange to trigger a move to a new page. 我们请求使用select元素的onchange来触发移动到新页面。

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. 这是因为它打破了用户的期望,并且浏览器(特别是IE <6)即使在使用键盘移动选项时也会触发更改事件,这使得仅限键盘的用户无法进行选择。

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. 当我通过鼠标或输入键实际选择了一个选项时,IE6 +和我测试的所有其他更现代的浏览器都会onchange select onchange Analytics for the application in question show that earlier IE browsers are essentially eradicated (< 0.01%) 有问题的应用程序的分析表明早期的IE浏览器基本上被根除(<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? 鉴于我们的用户只能使用键盘正确操作这些select元素,是否仍应将此功能视为可访问性的障碍? This behavior seems so common 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. 编辑:如果使用鼠标或键盘select IE的行为会有所不同。 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. 当用鼠标突出重点,通过键盘输入的选项不火onchange ,但按Tab键通过键盘关注它的时候,在onchange arrowing通过时不火。

Using the onchange event of the select element to navigate between pages can definitely pose an accessibility problem for keyboard-only users . 使用select元素的onchange事件在页面之间导航肯定会给仅限键盘的用户带来可访问性问题

There is at least one method of creating accessible select elements with onchange handlers and it has been on the interwebs since 2004! 至少有一种使用onchange处理程序创建可访问的select元素的方法,自2004年以来它一直在使用interwebs!

Direct link to the Accessible Select code. 直接链接到Accessible Select代码。

I agree with you that this type of functionality is very common. 我同意你的观点,这种功能很常见。 However, most sites use links instead of a <select> to achieve the effect (if I'm not mistaken). 但是,大多数网站使用链接而不是<select>来实现效果(如果我没有记错的话)。 IE it's the standard (pun intended). IE它是标准(双关语)。

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM