Name

selection — NN n/a IE 4 DOM n/a

Synopsis

The selection object represents zero or more characters that have been either explicitly selected in a document by the user or selected under script control. All actions on the content of a selection are done via a TextRange object, which can be created from the selection object (see the TextRange object). TextRange and selection objects are available in Navigator 4 only in the Win32 environment. The selection object belongs to the document object.

Navigator 4 offers script access to the text selected in a document via the document.getSelection( ) method.

In all browsers, be aware that clicking on buttons deselects the current text selection. Therefore, all scripted action involving selections must be triggered by select events or functions invoked by a timer (see the window.setTimeout( ) method description in Chapter 11).

Object Model Reference

IE

document.selection

Properties

type

    

Methods

clear( )

createRange( )

empty( )

Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.