MVC @Html.ActionLink
编辑,如果您运行JAWS之类的合规性程序,只需说“编辑”视觉效果就可以了,但是如果您是作为视觉障碍者进行查找的。成千上万的“编辑”并不能帮助您了解自己所处的位置。我需要法规遵从程序说“编辑CustomerX”,但将可视房地产降至“编辑”。删除和详细信息也是如此。
我尝试使用隐藏标签,但是没有用。我本以为标题可以做到这一点,但没有看到任何结果,并且读了一篇标题属性不好的文章。还在为此寻找更多论点。
搜索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 })
不确定这样做的效果如何。
答案 0 :(得分:3)
我发现,如果您在实际的<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 })