This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

rangeCount

Summary

Returns the number of ranges in a selection

Property of dom/Selectiondom/Selection

Syntax

Note: This property is read-only.

var rangecount = selObj.rangeCount;

Return Value

Returns an object of type NumberNumber

The number of ranges in a selection.

Examples

var selObj=window.selection();
var rangecount=selObj.rangeCount;

Notes

Remarks

Windows Internet Explorer 9-11 does not currently support multiple or disjointed selections in standards mode. This property always returns a 1 with a valid selection. It returns a 0 if removeRange or removeAllRanges have been applied, though calling isCollapsed is recommended instead to detect an empty range.

Before the user has clicked a freshly loaded page, the rangeCount is 0. A user can normally only select one range at a time, so the rangeCount will usually be 1. Scripting can be used (currently) in Gecko to make the selection contain more than 1 range.

Syntax

Standards information

Attributions