Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

Window: find() method

Non-standard: This feature is not standardized. We do not recommend using non-standard features in production, as they have limited browser support, and may change or be removed. However, they can be a suitable alternative in specific cases where no standard option exists.

TheWindow.find() method finds a string in a window sequentially.

Syntax

js
find(string, caseSensitive, backwards, wrapAround, wholeWord, searchInFrames, showDialog)

Parameters

string

The text string for which to search.

caseSensitive

A boolean value. Iftrue, specifies a case-sensitive search.

backwards

A boolean value. Iftrue, specifies a backward search.

wrapAround

A boolean value. Iftrue, specifies a wrap around search.

wholeWord

A boolean value. Iftrue, specifies a whole word search.

searchInFrames

A boolean value. Iftrue, specifies a search in frames.

showDialog

A boolean value. Iftrue, a search dialog is shown.

Return value

true if the string is found; otherwise,false.

Examples

HTML

html
<p>Apples, Bananas, and Oranges.</p><button type="button">Search for Apples</button><button type="button">Search for Bananas</button><button type="button">Search for Orange</button><p></p>

JavaScript

js
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");});

Result

Notes

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

Specifications

This is not part of any specification.

Browser compatibility

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp