TOC PREV NEXT INDEX

domref


window.getSelection()


Returns a selection object representing the selected item(s).

Syntax

selection = window.getSelection()
 

Parameters

selection is a selection object.

Example

function cutThis() {
 
  selObj = window.getSelection();
 
  selText = selObj.toSting();
 
  if len(selText) ...
 

Notes

The selection object returned by this method is automatically converted to a string as needed. If you asked for the len of selObj in the listing above, for example, the method would return the length of the object converted into a string (using the selection object's own toString() method. But you can also get the ranges in the selection and you can navigate through the selected nodes using these range objects.

See the nsISelection interface in mozilla for more information about selection objects and the services they provide for manipulating selections:

http://lxr.mozilla.org/seamonkey/source/content/base/public/nsISelection.idl

Specification

DOM Level 0. Not part of specification.
 


Netscape Communications
http://developer.netscape.com
TOC PREV NEXT INDEX