HTML select onchange 可访问性问题

发布于 2024-10-18 21:43:30 字数 614 浏览 2 评论 0原文

我们有一个使用 select 元素的 onchange 来触发移动到新页面的请求。

过去,我读过的网络可访问性文献通常建议不要这样做。这是因为它打破了用户的期望,并且浏览器(特别是 IE < 6)即使在使用键盘移动选项时也会触发更改事件,使得仅使用键盘的用户无法做出选择。

当通过鼠标或 Enter 键实际选择选项时,IE6+ 和我测试过的所有其他更现代的浏览器都会触发 select onchange 。对相关应用程序的分析表明,早期的 IE 浏览器基本上已被淘汰 (< 0.01%)

鉴于我们的用户将能够仅使用键盘正确操作这些 select 元素,那么此功能是否应该仍然存在被认为是无障碍的障碍吗?这种行为如今似乎很常见,我也想知道它是否真的仍然以一种有意义的方式打破了用户的期望?

编辑:如果选择通过鼠标或键盘获得焦点,IE 的行为会有所不同。当使用鼠标聚焦时,通过选项进行键盘输入不会触发 onchange,但是当通过键盘按 Tab 键进行聚焦时,onchange 会在箭头穿过时触发。

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 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. 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

月棠 2024-10-25 21:43:30

使用 select 元素的 onchange 事件在页面之间导航绝对可以对仅使用键盘的用户造成可访问性问题

至少有 一种使用 onchange< 创建可访问的 select 元素的方法/code> handlers并且它自 2004 年以来一直出现在互联网上!

直接链接到 Accessible Select 代码。

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.

﹏雨一样淡蓝的深情 2024-10-25 21:43:30

我同意你的观点,这种类型的功能很常见。然而,大多数网站使用链接而不是

在此处输入图像描述

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). I.E. it's the standard (pun intended).

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文