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
BCD tables only load in the browser
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
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);