search.search()

Perform a search using the search engine specified, or the default search engine if no search engine is specified.

The results will be displayed in a new tab, or if the tabId argument is given, in the tab identified by this.

To use this function in your extension you must ask for the "search" manifest permission.

To get the installed search engines, use search.get().

Syntax

browser.search.search(
  searchProperties       // object
)

Parameters

searchProperties

object. An object with the following properties:

query
string. The search query.
engineOptional

string. The name of the search engine. If the search engine name you specify doesn't exist, the function throws an error. If this property is omitted the default search engine will be used.

tabIdOptional

integer. An optional identifier for the tab you want to execute the search in. If this property is omitted the search results will be displayed in a new tab.

Return value

None.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxOperaFirefox for Android
Basic supportChrome No support NoEdge No support NoFirefox Full support 63Opera No support NoFirefox Android No support No

Legend

Full support  
Full support
No support  
No support

Examples

Search using the default search engine. The results will be shown in a new tab:

function search() {
  browser.search.search({
    query: "styracosaurus"
  });
}

browser.browserAction.onClicked.addListener(search);

Search using Wikipedia. The results will be shown in a new tab:

function search() {
  browser.search.search({
    query: "styracosaurus",
    engine: "Wikipedia (en)"
  });
}

browser.browserAction.onClicked.addListener(search);

Search using Wikipedia. The results will be shown in the active tab:

function search(tab) {
  browser.search.search({
    query: "styracosaurus",
    engine: "Wikipedia (en)",
    tabId: tab.id
  });
}

browser.browserAction.onClicked.addListener(search);

Document Tags and Contributors

Contributors to this page: evilpie, wbamberg, Kwan, smile4ever, kernp
Last updated by: evilpie,