Chrome 27:新标签页扩展无法从多功能框窃取焦点 [英] Chrome 27: New Tab Page extension can't steal focus from Omnibox

查看:12
本文介绍了Chrome 27:新标签页扩展无法从多功能框窃取焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Chrome 27 中,覆盖 Chrome 新标签页的扩展程序似乎无法像以前版本的 Chrome 那样将注意力从 Chrome 的多功能框上移开.

With Chrome 27, it seems that extensions that override Chrome's New Tab Page can't take focus away from Chrome's Omnibox like they used to in previous versions of Chrome.

是否有一种新方法可以将输入框聚焦到新标签页中,或者是否已完全禁用此功能?:(

Is there a new way to focus an input box in a New Tab Page, or has this functionality been disabled completely? :(

为了测试这个,创建一个包含三个文件的扩展文件夹:

To test this, create an extension folder with three files:

1.manifest.json:

{
    "name": "Focus Test",
    "version": "0",
    "minimum_chrome_version": "27",
    "chrome_url_overrides": {
        "newtab": "newTab.html"
    },
    "manifest_version": 2
}

2.focus.js:

document.getElementById('foo').focus();

3.newTab.html:

<html>
    <body>
        <input id="foo" type="text" />
        <script type="text/javascript" src="focus.js"></script>
    </body>
</html>

然后,当您加载扩展程序并打开新标签页时,输入字段不会聚焦在新标签页上.

Then, when you load the extension and open a new tab, the input field does not get focused on the new tab page.

我也尝试将 autofocus 属性添加到 input 字段,但也没有运气.扩展程序的新标签页无法将注意力从 Chrome 的多功能框上移开.

I have also tried adding the autofocus attribute to the input field, but no luck either. The extension's new tab page can't take focus away from Chrome's Omnibox.

有什么想法吗?这是错误还是新功能"?

Any ideas? Is this a bug or a new "feature"?

推荐答案

根据 Chrome 扩展文档,

As per the Chrome Extension Documentation,

不要依赖具有键盘焦点的页面.当用户创建新标签时,地址栏总是首先获得焦点.

Don't rely on the page having the keyboard focus. The address bar always gets the focus first when the user creates a new tab.

请参阅此处的参考:覆盖页面

这篇关于Chrome 27:新标签页扩展无法从多功能框窃取焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆