我正在使用WebBrowser对象来呈现以表格格式呈现的文本。 此WebBrowser嵌入在Eclipse插件项目中。为了符合可访问性要求,我需要在使用向上/向下箭头键浏览条目时使WebBrower中的每个条目都具有焦点,以便屏幕阅读器可以读出文本。
我可以通过java代码检测上/下箭头键,但是我没有看到要在条目上设置焦点。 的document.getElementById( “+ newPos +”)聚焦();
我认为这是因为只有按钮/表单/文本字段才能在HTML中有焦点。
元素有没有办法集中注意力?或者,当按下向上/向下箭头键时,WebBrowser对象是否有办法在条目中拼出相关文本?
非常感谢。
答案 0 :(得分:0)
我在设置焦点而没有与之相关的高度时遇到了问题,尽管我没有让任何听众对其进行检查。
document.getElementById(newPos).focus();
但是,如果不改变newPos代码,则会出错。
设置了高度,并使用该更改,它允许我在两个div之间切换焦点。
<body onload="var test = 'test2'; document.getElementById(test).focus()">
<div id="test">
The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.<br />
The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.<br />
The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.<br />
</div>
<div id="test2" style="height: 50px; overflow: auto">
The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.<br />
The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.<br />
The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.<br />
</div>
将测试从'test2'更改为测试以查看差异。在第二个例子中它集中,我可以按键,它会上下移动。我认为这与导致它的滚动有关。
希望有所帮助。