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. -
engine
Optional -
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. -
tabId
Optional -
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
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
search |
No |
No |
63 |
? |
No |
No |
? |
? |
No |
? |
? |
? |
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);
Example extensions
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/search/search