Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome 27: New Tab Page extension can't steal focus from Omnibox

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

like image 283
Chris McFarland Avatar asked May 22 '13 06:05

Chris McFarland


People also ask

How do I focus Chrome extensions?

Block distracting websites and pages in just a few clicks. Just Focus is a free chrome extension that helps you avoid distractions and enables you to focus on your real work. Simply add a website to your block list and hit "Start Focusing" - you'll increase your working efficiency and get more done.

Where is the Omnibar in Chrome?

The bar at the top of Chrome is called the omnibox (or Omnibar). It combines your regular address bar and the Google search box into one area in your browser. It's a powerful tool that can be used in a variety of ways.


1 Answers

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

like image 108
John Woodruff Avatar answered Sep 22 '22 16:09

John Woodruff