docs.rodeo

MDN Web Docs mirror

omnibox

{{AddonSidebar}} 

Enables extensions to implement customized behavior when the user types into the browser’s address bar.

When the user focuses the browser’s address bar and starts typing, the browser displays a drop-down list containing suggested pages based on what they typed. This gives the user a quick way to access, for example, pages from their history or bookmarks.

The omnibox API provides the extension a way to customize the suggestions displayed in the drop-down, when the user enters a keyword defined by the extension. It works as follows:

  1. First, the extension must include an “omnibox” key in its manifest.json file, which defines a keyword.
  2. When the user focuses the address bar and types the keyword followed by a space, the extension gets an {{WebExtAPIRef("omnibox.onInputStarted")}}  event.
  3. Optionally, the extension can call {{WebExtAPIRef("omnibox.setDefaultSuggestion()")}}  to define the first suggestion displayed in the address bar drop-down.
  4. As the user continues to type characters, the extension gets {{WebExtAPIRef("omnibox.onInputChanged")}}  events. The event listener is passed the value the user has typed and can populate the address bar drop-down with suggestions. If the extension sets a default suggestion using {{WebExtAPIRef("omnibox.setDefaultSuggestion()")}} , this suggestion is displayed first in the drop-down.
  5. If the user accepts a suggestion, the extension gets an {{WebExtAPIRef("omnibox.onInputEntered")}}  event. The event listener is passed the accepted suggestion.
  6. If the user deletes a suggestion, the extension gets an {{WebExtAPIRef("omnibox.onDeleteSuggestion")}}  event.
  7. If the user dismisses the drop-down, the extension gets an {{WebExtAPIRef("omnibox.onInputCancelled")}}  event.

Types

Functions

Events

{{WebExtExamples("h2")}} 

Browser compatibility

{{Compat}} 

[!NOTE] This API is based on Chromium’s chrome.omnibox API.

In this article

View on MDN