Find Dialog: window.find()

JavaScript FAQ | JavaScript Dialogs FAQ  

Question: How do I invoke the browser's Find dialog from JavaScript?

Answer: In Firefox and some Gecko browsers, you can display the browser's Find dialog by calling window.find('text',0,0,0,0,0,1) with the last (seventh) parameter true or 1. In Netscape Navigator and Firefox, you can also use the window.find() method without parameters. The Find dialog may look as shown below. (The actual behavior depends on the parameters passed, the browser and OS version; the screenshot below shows Firefox 3.6 under Windows XP with Windows Classic UI theme.)


Try these window.find() techniques here and below:

This example was created using the following code:
<input type=button value="window.find()"
alert('Your browser does not support \'window.find()\'!')
<input type=button value="window.find('text',0,0,0,0,0,1)"
alert('Your browser does not support \'window.find()\'!')
Internet Explorer does not support window.find(). However, in most browsers including Internet Explorer, you can write a script that finds a user-defined string on the page. For more information on this technique, see Searching for text.

The general syntax of the window.find() method is as follows:

window.find()             // Netscape and Firefox only!

You can use up to seven parameters; they are explained below. All parameters are optional; the default is false or an empty string.
sText  The text string to search for.
bCaseSensitive     Perform case-sensitive search if true or 1.
bUpward  Search upward if true or 1.
bWrapped  Search in wrapped-around text if true or 1.
bWholeWord  Search whole words if true or 1.
bFrames  Search in frames if true or 1.
bShowDialog Show the Find dialog if true or 1.

See also other JavaScript dialogs:

  • Alert (message box) dialog
  • Confirm dialog
  • Prompt dialog
  • Print dialog
  • Add Favorite dialog
  • Copyright © 1999-2011,