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.)

 window.find('text',0,0,0,0,0,1)

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

This example was created using the following code:
<input type=button value="window.find()"
onclick="if(window.find)window.find();
else 
alert('Your browser does not support \'window.find()\'!')
">
<input type=button value="window.find('text',0,0,0,0,0,1)"
onclick="if(window.find)window.find('text',0,0,0,0,0,1);
else 
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(parameters)
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:

Copyright © 1996-2018, JavascriptFAQ.net.