Web/API/Window/find

From Get docs

Non-standard This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.


Note: Support for Window.find() might change in future versions of Gecko. See bug 672395.


The Window.find() method finds a string in a window.

Syntax

window.find(aString, aCaseSensitive, aBackwards, aWrapAround,
            aWholeWord, aSearchInFrames, aShowDialog);
aString
The text string for which to search.
aCaseSensitive
Boolean. If true, specifies a case-sensitive search.
aBackwards
Boolean. If true, specifies a backward search.
aWrapAround
Boolean. If true, specifies a wrap around search.
aWholeWord Unimplemented
Boolean. If true, specifies a whole word search. This is not implemented; see bug 481513.
aSearchInFrames
Boolean. If true, specifies a search in frames.

Returns

true if the string is found; otherwise, false.

Example

JavaScript

findString = function findText(text) {
  alert("String \x22" + text + "\x22 found? " + window.find(text));
}

HTML

<p>Apples, Bananas, and Oranges.</p>
<button type="button" onClick='findString("Apples")'>Search for Apples</button>
<button type="button" onClick='findString("Banana")'>Search for Banana</button>
<button type="button" onClick='findString("Orange")'>Search for Orange</button>

Result

Notes

In some browsers, Window.find() selects (highlights) the found content on the site.

Specification

This is not part of any specification.

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet

find

Experimental'Non-standard'

Chrome

Full support 1

Edge

Full support 79

Firefox

Full support 1

IE

No support No

Opera

Full support 15

Safari

Full support 3

WebView Android

Full support 1

Chrome Android

Full support 18

Firefox Android

Full support 4

Opera Android

Full support 14

Safari iOS

Full support 1

Samsung Internet Android

Full support 1.0

Legend

Full support  
Full support
No support  
No support
Experimental. Expect behavior to change in the future.'
Experimental. Expect behavior to change in the future.
Non-standard. Expect poor cross-browser support.'
Non-standard. Expect poor cross-browser support.