简体   繁体   English

Web 辅助功能屏幕阅读器未读取 JavaScript 弹出对话框

[英]JavaScript Pop-Up Dialog Not Being Read by Web Accessibility Screen Reader

I have a project requirement in which the web page I am building in question needs to be read by the JAWS screen reading software, but the client only has access to JAWS 11 as their latest version.我有一个项目要求,其中我正在构建的网页需要由 JAWS 屏幕阅读软件读取,但客户端只能访问 JAWS 11 作为其最新版本。

We currently have JavaScript-based pop-up dialogs for many of the forms on the web and right now a big problem is that the JAWS 11 software cannot read the below pop-up text.我们目前为网络上的许多表单提供基于 JavaScript 的弹出对话框,现在一个大问题是 JAWS 11 软件无法读取下面的弹出文本。 What is wrong with the pop-up dialog below (in HTML)?下面的弹出对话框(在 HTML 中)有什么问题?

<div class="modal fade" id="EditContentModal" tabindex="-1" role="dialog" aria-labelledby="editContentDialogTitle" 
aria-hidden="true" title="Edit Content Pop-up Dialog Window" aria-describedby="editContentDialogTitle">
    <div class="modal-dialog"  >
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close" value="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="editContentDialogTitle">Edit: Content ID <span id="lblContentid"></span></h4>
            </div>

            <div class="modal-body">
                <div class='row'>
                    <div class='col-md-8'>
                        <div class='form-group'>
                            <label for="edit_Contentnumber">Content Number</label>
                            <input type="text" class="form-control" max-length="20" id="edit_Contentnumber" />
                        </div>
                    </div>
                </div>
                <div class='row'>
                    <div class='col-md-8'>
                        <div class='form-group'>
                            <label for="edit_Educationalinsitution">Educational Insitution</label>
                            <input type="text" class="form-control" max-length="100" id="edit_Educationalinsitution" />
                        </div>
                    </div>
                </div>
                 <div class='row'>
                    <div class='col-md-8'>
                        <div class='form-group'>
                            <label for="edit_TotalAmountforRecovery">Total Amount Available for Recovery</label>
                            <input type="text" class="money form-control" max-length="10" id="edit_TotalAmountforRecovery" />
                        </div>
                    </div>
                </div>
                <div class='row'>
                    <div class='col-md-8'>
                        <div class='form-group'>
                            <label for="edit_source">Source</label>
                            <select id="edit_source" class="form-control"></select>
                        </div>
                    </div>
                </div>
                <div class='row'>
                    <div class='col-md-8'>
                         <div class='form-group'>
                            <label for="edit_indemletterdate">Indemnification Letter Date</label>
                            <input type="text" class="form-control datepicker" id="edit_indemletterdate" />
                        </div>
                    </div>
                </div>
                <div class='row'>
                    <div class='col-md-8'>
                        <div class='form-group'>
                            <label for="edit_Contentreceiveddate">Content Received Date</label>
                            <input type="text" class="form-control datepicker" id="edit_Contentreceiveddate" />
                        </div>
                    </div>
                </div>
                <div class='row'>
                    <div class='col-md-8'>
                        <div class='form-group'>
                            <label for="edit_site">Site</label>
                            <select id="edit_site" class="form-control">
                            </select>
                            @*<input type="text" class="form-control" max-length="10" id="edit_site" />*@
                        </div>
                    </div>
                </div>
                <div class='row'>
                    <div class='col-md-8'>
                        <div class='form-group'>
                            <label for="edit_status">Status</label>
                            <select id="edit_status" class="form-control">
                            </select>
                        </div>
                    </div>
                </div>

                <input type="hidden" id="edit_Contentid" />
                <img id="displayBlockUI" alt="Spinner" src="~/Images/loader2.gif" width="32" height="32" style="display:none" />
            </div>
            <div class="modal-footer">
                <button type="button" id="cancel_edit" class="btn btn-default" data-dismiss="modal" value="Close">Close</button>
                <button type="button" id="save_edit" class="btn btn-primary" value="Save">Save</button>
            </div>
        </div>
    </div>
</div>

Setting the main content to aria-hidden='true' tells the screen reader to stop reading the content there.将主要内容设置为 aria-hidden='true' 告诉屏幕阅读器停止阅读那里的内容。

Try using aria-hidden='false'尝试使用 aria-hidden='false'

How are you opening the modal?你是怎么打开模态的? Because with a tabindex of -1 on the wrapper div, you will only be able to send the screenreader and keyboard focus to the modal via JavaScript.因为包装器 div 上的 tabindex 为 -1,您将只能通过 JavaScript 将屏幕阅读器和键盘焦点发送到模态。 In that case it's best to make moving the focus part of the script which opens the modal.在这种情况下,最好移动打开模态的脚本的焦点部分。

On the other hand, if it's opened via a link, you can just remove that tabindex attribute altogether and put the id of the wrapper div in the link href, eg <a href=#EditContentModal>另一方面,如果它是通过链接打开的,您可以完全删除该 tabindex 属性并将包装器 div 的 id 放在链接 href 中,例如<a href=#EditContentModal>

Either way, remember to send focus back to where it started when the modal is closed.无论哪种方式,请记住在模态关闭时将焦点发送回它开始的位置。

Edited to clarify: the tabindex="-1" attribute on your wrapper div is preventing keyboard access.编辑以澄清:包装器 div 上的 tabindex="-1" 属性阻止键盘访问。 Remove it.去掉它。 See MDN's tabindex reference : a negative value means that the element should be focusable, but should not be reachable via sequential keyboard navigation.请参阅MDN 的 tabindex 参考:负值意味着该元素应该是可聚焦的,但不应通过顺序键盘导航访问。

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

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