c# - 更改编辑 | 详情 | 删除操作链接,为 508 位合规性读者提供替代文本
问题描述
MVC @Html.ActionLink
Edit,如果您运行像 JAWS 这样的合规程序,只需说“编辑”视觉就可以了,但如果您是作为视障人士进行查找。数以千计的“编辑”并不能帮助您了解您所处的位置。我需要合规计划说“编辑 CustomerX”,但将视觉空间保持在“编辑”。删除和详细信息也是如此。
我曾尝试使用隐藏标签,但没有奏效。本来以为titles会做,但是没有看到任何结果,看了一篇title属性不好的文章。仍在寻找更多关于此的论据。
不利于 508 搜索正常设置:
@Html.ActionLink("Edit", "Edit", new { id = item.CustomerID })
不工作隐藏标签:
@Html.ActionLink("Edit", "Edit", new { id = item.CustomerID })
<label class="hidden">  @item.CustomerName  </label>
试图找出利弊:
@Html.ActionLink("Edit", "Edit", new { id = item.ApplicationID }, new{ title="Edit " + item.CustomorName })
虽然不确定这有多好。
解决方案
我发现如果您在实际<a>
标签中有唯一标识符并使用 CSS 隐藏它,那么在 JAWS 和其他屏幕阅读器中更容易理解。不幸的是,我们需要使用@Url.Action
而不是@Html.ActionLink
来实现这一点。
<a href="@Url.Action("Edit", "ControllerName")">Edit <span class="visual-hidden"> for @item.CustomorName</span></a>
和CSS:
.visual-hidden {
position: absolute !important;
height: 1px; width: 1px;
overflow: hidden;
clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
clip: rect(1px, 1px, 1px, 1px);
}
另一个(更简单)的解决方案是使用aria-label
HTML 属性。aria-label
这是有关该属性的更多信息的链接。这将使屏幕阅读器知道编辑按钮的用途,您可以使用以下@Html.ActionLink
方法:
@Html.ActionLink("Edit", "Edit", new { id = item.ApplicationID }, new{ aria_label="Edit for " + item.CustomorName })
推荐阅读
- javascript - JavaScript 内置字符集库
- python - 不使用 .split() 函数从字符串中提取单词
- java - 尽管凭据正确,但 SQL 错误 1045
- python - google cloud function python CORS error 请求的资源上不存在“Access-Control-Allow-Origin”标头。
- android - 为什么 RecyclerViewAdapter DummyContent 元素和方法是静态的?
- go - 构建一个多可执行的 Go 项目
- javascript - 表元素使用 javascript 连接过早关闭
- php - php的解释器。阅读、翻译和执行源代码的指令?
- css - 使 Angular 应用程序中的背景图像加载速度更快
- arrays - 如何获得3个值的打印?