Chrome 27: new tab page extension cannot steal focus with Omnibox

In Chrome 27, it seems that extensions that override the Chrome New Tab page cannot divert attention from Chrome Omnibox, as it was in previous versions of Chrome.

Is there a new way to focus the input field on the page of a new tab or is this function completely disabled ?: (

To verify 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 download the extension and open a new tab, the input field does not focus on the new tab.

I also tried adding the autofocus attribute to the input field, but no luck. A new extension bookmark cannot distract attention from Chrome Omnibox.

Any ideas? Is this a bug or a new โ€œfeatureโ€?

+6
source share
1 answer

According to the Chrome extension documentation,

Do not rely on the keyboard focus page. The address bar always gets focus when the user creates a new tab.

See link here: Override Pages

+4
source

Source: https://habr.com/ru/post/945541/


All Articles