find.highlightResults()

Highlights the results of a previous call to find.find().

When an extension calls find(), the matches are not highlighted automatically, but they are stored by the browser. Call highlightResults() to highlight them.

Note that the stored results are global across all extensions, so for example, if extension A calls find("apple"), then extension B calls find("banana"), then if extension A calls highlightResults(), the results for "banana" will be highlighted.

Syntax

js
browser.find.highlightResults(
  options // optional object
)

Parameters

options Optional

object. An object specifying additional options. It may take any of the following properties, all optional:

tabId

integer. ID of the tab to highlight. Defaults to the active tab.

rangeIndex

integer. Index of the range to highlight. Defaults to highlighting all ranges.

noScroll

boolean. Don't scroll to highlighted item. Defaults to true.

Return value

None.

Examples

Search the active tab for "banana", log the number of matches, and highlight them:

js
function found(results) {
  console.log(`There were: ${results.count} matches.`);
  if (results.count > 0) {
    browser.find.highlightResults();
  }
}

browser.find.find("banana").then(found);

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Firefox for Android
Safari on iOS
highlightResults
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – Full support
Firefox 57 (Release date: 2017-11-14)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – No support
Safari
footnote No support
Firefox for Android – No support
Firefox for Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support