指定屏幕 Reader 文本框公告

Specifying Screen Reader Announcements for Textboxes

我花了几个小时寻找解决方案并通读了类似问题后发布了一个新问题。

使用 NVDA,当文本框获得焦点时,将读取标签(组织),然后是 aria-describedby content(200 West Street, New York, NY),然后是值(Goldman Sachs):

<label for="organization">Organization</label>
<input type="text" id="organization" value="Goldman Sachs" aria-describedby="organizationLocation" />
<span id="organizationLocation">200 West Street, New York, NY</span>

出于明显的原因,在这种情况下,最好先阅读标签(组织),然后是价值(高盛),然后是内容描述的咏叹调(200 West Street, New York, NY) .

我也尝试从 aria-describedby 属性引用文本框,尽管文本框 (Goldman Sachs) 的值重复,在标签(组织)之后和组织位置之后宣布一次:

<label for="organization">Organization</label>
<input type="text" id="organization" value="Goldman Sachs" aria-describedby="organization organizationLocation" />
<span id="organizationLocation">200 West Street, New York, NY</span>

实现所需功能有多难?

您通常不想规定屏幕 reader 如何显示元素。不同的屏幕 reader 可能会以不同的方式宣布事情。您是否使用 JAWS 或 VoiceOver (Mac) 测试听到命令?

除了角色和值之外,元素还可以具有“可访问的名称”和“可访问的描述”。 (请参阅 WCAG 4.1.2 and the "Accessible Name Computation")。名称和值通常先公布,然后是描述,尽管如您所述,您在描述 之后听到的是值 。这只是NVDA 选择如何公布它,这将是 NVDA 用户预期的顺序。如果您更改该顺序,可能会使 NVDA 用户感到困惑。