Chrome 27:新标签页扩展程序无法窃取Omnibox的焦点 [英] Chrome 27: New Tab Page extension can't steal focus from Omnibox

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

问题描述

使用Chrome 27,似乎覆盖Chrome新标签页的扩展程序无法像以前的Chrome版本那样将注意力集中在Chrome的多功能框中。

$ b

是否有新的方式将输入框集中在新标签页中,或者是否已完全禁用此功能? :(b / b
$ b $ p

$ b

1。manifest .json:

  {
name:焦点测试,
$,$,$ bmanifest_version:2
}

2. focus.js:

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

$ b

3. newTab.html:

 < html> 
< body>
< input id =footype =text/>
< script type =text / javascriptsrc =focus.js>< / script>
< / body>
< / html>

然后,当您加载扩展并打开一个新选项卡时,输入字段不会专注于新标签页。



我也试过了将自动对焦属性添加到输入字段中,但没有运气。该扩展程序的新标签页无法从Chrome的Omnibox中重点关注。



有什么想法?这是一个错误还是一个新的功能?

解决方案

根据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.

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"?

解决方案

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.

See reference here: Override Pages

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

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