简体   繁体   English

如何使屏幕阅读器可以访问自定义输入文本框?

[英]How to make custom input text box accessible to screen readers?

I have a plugin jQuery Terminal and I want to make it accessible to screen readers. 我有一个jQuery Terminal插件,我想让屏幕阅读器可以访问它。 What should I do to make the input of text accessible? 我应该怎么做才能使文本输入变得可访问?

Generated html look like this: 生成的html看起来像这样:

<div class="cmd" style="width: 100%; visibility: visible;">
    <span class="prompt">
        <span>&gt;&nbsp;</span>
    </span>
    <span>Before curosr</span>
    <span class="cursor">&nbsp;</span>
    <span>after cursor</span>
    <textarea autocapitalize="off" spellcheck="false" class="clipboard">
    </textarea>
</div>

As far as I can tell the textarea is always in focus when entering text (I had it for mobile but then turn it on for all browsers). 据我所知,输入文本时,文本区域始终处于焦点位置(我在移动设备上拥有它,但是在所有浏览器中都将其打开)。

I'm testing using NVDA on the jQuery Terminal test page. 我正在jQuery Terminal测试页上使用NVDA进行测试。 There is a <div class="terminal-output"> I added a role="alert" attribute and my screen reader is reading out all the textual content that is added to the terminal-output . 有一个<div class="terminal-output">我添加了role="alert"属性,并且我的屏幕阅读器正在读取添加到terminal-output所有文本内容。

However, it really depends on what you actually want to achieve with your accessibility. 但是,这实际上取决于您实际上希望通过可访问性实现什么。 What do you want the screen reader to actually read? 您想要屏幕阅读器实际阅读什么? You'll need to experiment, but take a look at aria roles and ways to callout things that you want the reader to read and present to your user. 您将需要进行实验,但要了解aria角色以及标注出希望读者阅读并呈现给用户的内容的方式。

See my screen reader log and how it reads out what is contained in the "console" window: 请参阅我的屏幕阅读器日志,以及它如何读取“控制台”窗口中包含的内容:

屏幕阅读器日志

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

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