把重点放在浏览器上 [英] Give focus to browser
问题描述
ExternalInterface
来交谈一些JavaScript函数。 / p> JavaScript通过 因此,我的问题:是否有可能以编程方式专注于浏览器的铬?更好的是,如果我可以模仿向前的和向后切换。另外,我希望避免在闪光灯之前/之后添加额外的可放置组件,除非我们可以使它们对鼠标和键盘都不可见。 http://jsfiddle.net/4NA5u/1/ 。 I'm working on keyboard accessibility. I have a flash object which sits inside a page, and to stop the focus getting trapped inside it, I've added tab listeners which talk through The JavaScript looks for the next available element with a Hence my question: Is it possible to programatically give focus to the browser's chrome? Even better if I can mimic both forward and backward tabbing. Also I'd like to avoid adding extra tabbable components before/after the flash if possible, unless I can make them effectively invisible to both the mouse and keyboard. Setting the focus to a dummy anchor with no text content, at the top of the document, seems to work: 这篇关于把重点放在浏览器上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! tabIndex
查找下一个可用元素,并调用 focus() / code>就可以了。到现在为止还挺好。但是,如果插件是页面上的最后一个可放置项目(或者在反向标签时为第一个项目),则不存在切换到的元素。通常这会把焦点设置到浏览器窗口,所以我想保持这种行为。
将焦点设置为一个没有文本内容的虚拟锚点,在文档的顶部,似乎工作:
document.getElementsByTagName( 'A')[0] .focus();
ExternalInterface
to some JavaScript functions.tabIndex
and calls focus()
on it. So far so good. But if the plugin is the last tabbable item on the page (or first when reverse-tabbing), there is no element to switch to. Normally this would set focus to the browser window, so I'd like to keep that behaviour.document.getElementsByTagName('a')[0].focus();