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.

removeRange

Summary

Removes a range from a selection.

Method of dom/Selectiondom/Selection

Syntax

var result = selObj.removeRange(/* see parameter list */);

Parameters

range

Data-type
Range

Range to remove.

Return Value

Returns an object of type NumberNumber

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Examples

/* In gecko Programmaticaly, more than one range can be selected.
 * This will remove all ranges except the first. see Compatibility Notes below */
selObj = window.getSelection();
if(selObj.rangeCount > 1) {
 for(var i = 1; i < selObj.rangeCount; i++) {
  selObj.removeRange(selObj.getRangeAt(i));
 }
}

Notes

Remarks

Windows Internet Explorer 9-11 does not currently support multiple or disjointed selections in standards mode.

Syntax

Standards information

Attributions