findbar

In Gecko 1.9, the findbar widget moved into toolkit, so it's available to any XUL application, as well as extensions.

For example, the standard findbar in Firefox 3.5 looks like this on the Mac:

findbar.png

You may attach a findbar to a particular browser element by either setting the findbar's browserid attribute to the ID of the browser element before the findbar element is bound, or by setting the findbar's browser property to the browser element itself.

Attributes
browserid, findnextaccesskey, findpreviousaccesskey, highlightaccesskey, matchcaseaccesskey
Properties
browser, findMode
Methods
close, onFindAgainCommand, open, startFind, toggleHighlight

Example

<browser type="content-primary" flex="1" id="content" src="about:blank"/>
<findbar id="FindToolbar" browserid="content"/>

Attributes

browserid
Type: string
The ID of the browser element to which the findbar is attached.  This attribute is only used when the findbar is constructed.  You should use the browser property to get and set this value from a script.
findnextaccesskey
Type: string
The access key for the "Find Next" toolbar button in the findbar.
findpreviousaccesskey
Type: string
The access key for the "Find Previous" toolbar button in the findbar.
highlightaccesskey
Type: string
The access key for the "Highlight" toolbar button in the findbar.
matchcaseaccesskey
Type: string
The access key for the "Match case" checkbox in the findbar.

Properties

Inherited Properties
align, attributes, allowEvents, baseURI, boxObject, builder, childElementCount, childNodes, children, className, clientHeight, clientLeft, clientTop, clientWidth, collapsed, contextMenu, controllers, database, datasources, dir, firstChild, firstElementChild, flex, height, hidden, id, lastChild, lastElementChild, left, localName, maxHeight, maxWidth, menu, minHeight, minWidth, namespaceURI, nextElementSibling, nextSibling, nodeName, nodeType, nodeValue, observes, ordinal, orient, ownerDocument, pack, parentNode, persist, prefix, previousElementSibling, previousSibling, ref, resource, scrollHeight, scrollLeft, scrollTop, scrollWidth, statusText, style, tagName,textContent, tooltip, tooltipText, top, width

browser
Type: browser element
Lets you set and get the browser in which the findbar is located.
findMode
Type: integer
Read only.  The find mode in use.  Possible values are:
  • FIND_NORMAL (0): Normal find
  • FIND_TYPEAHEAD (1): Typeahead find
  • FIND_LINKS (2): Link find

Methods

Inherited Methods
addEventListener(), appendChild(), blur, click, cloneNode(), compareDocumentPosition, dispatchEvent(), doCommand, focus, getAttribute(), getAttributeNode(), getAttributeNodeNS(), getAttributeNS(), getBoundingClientRect(), getClientRects(), getElementsByAttribute, getElementsByAttributeNS, getElementsByClassName(), getElementsByTagName(), getElementsByTagNameNS(), getFeature, getUserData, hasAttribute(), hasAttributeNS(), hasAttributes(), hasChildNodes(), insertBefore(), isDefaultNamespace(), isEqualNode, isSameNode, isSupported(), lookupNamespaceURI, lookupPrefix, normalize(), querySelector(), querySelectorAll(), removeAttribute(), removeAttributeNode(), removeAttributeNS(), removeChild(), removeEventListener(), replaceChild(), setAttribute(), setAttributeNode(), setAttributeNodeNS(), setAttributeNS(), setUserData

close()
Return type: no return value
Closes the notification or findbar and removes it from its enclosing notificationbox or findbar.
open( mode )
Return type: no return value
Opens the findbar using the specified mode, which should be one of FIND_NORMAL, FIND_TYPEAHEAD, or FIND_LINKS.  If you don't pass a mode, the last-used mode for the same findbar is used.  If the findbar hasn't been used before, FIND_NORMAL is the default.
onFindAgainCommand( findPrevious )
Return type: no return value
Call this method to handle your application's "find next" and "find previous" commands.  You should specify true as the input parameter to perform a "find previous" operation, or false to perform a "find next."
startFind( mode )
Return type: no return value
Call this method to handle your application's "find" command.  This opens the findbar, focuses the edit field for the search term, and selects its contents.  The first time this is called for a given findbar, the findbar will flash to draw attention to itself.  The mode should be one of FIND_NORMAL, FIND_TYPEAHEAD, or FIND_LINKS.  If you don't pass a mode, the last-used mode for the same findbar is used.  If the findbar hasn't been used before, FIND_NORMAL is the default.
toggleHighlight( highlight )
Return type: no return value
Turns highlighting of text matching the search term on and off; specify false to disable highlighting or true to enable it.

Document Tags and Contributors

 Contributors to this page: Sheppy, Wladimir_Palant, Standard8, Jürgen Jeka
 Last updated by: Sheppy,