files/en-us/web/api/window/find/index.md
{{ApiRef}}{{Non-standard_Header}}
[!NOTE] Support for
Window.find()might change in future versions of Gecko. See Firefox bug 672395.
The Window.find() method finds a string in a window sequentially.
find(string, caseSensitive, backwards, wrapAround, wholeWord, searchInFrames, showDialog)
string
caseSensitive
true, specifies a case-sensitive search.backwards
true, specifies a backward search.wrapAround
true, specifies a wrap around search.wholeWord
true, specifies a whole word search.searchInFrames
true, specifies a search in frames.showDialog
true, a search dialog is shown.true if the string is found; otherwise, false.
<p>Apples, Bananas, and Oranges.</p>
<button type="button" id="find-apples">Search for Apples</button>
<button type="button" id="find-bananas">Search for Bananas</button>
<button type="button" id="find-orange">Search for Orange</button>
<p id="output"></p>
function findString(text) {
document.querySelector("#output").textContent = `String found? ${window.find(
text,
)}`;
}
document.getElementById("find-apples").addEventListener("click", () => {
findString("Apples");
});
document.getElementById("find-bananas").addEventListener("click", () => {
findString("Bananas");
});
document.getElementById("find-orange").addEventListener("click", () => {
findString("Orange");
});
{{EmbedLiveSample("Examples")}}
In some browsers, Window.find() selects (highlights) the found content on
the site.
This is not part of any specification.
{{Compat}}