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.

setStart

Summary

Sets the starting point of a range

Method of dom/Rangedom/Range

Syntax

var result = range.setStart(/* see parameter list */);

Parameters

startNode

Data-type
DOM Node


Node in the document hierarchy.


startOffset

Data-type
Number


Specifies the offset value for the starting point.

Return Value

Returns an object of type NumberNumber

Type: HRESULT

This method can return one of these values.

Return code Description
S_OK The operation completed successfully.
InvalidStateError detach has been invoked on the object.
W3Exception_DOM_INDEX_SIZE_ERR offset is negative or greater than the number of child units in refNode.

Examples

var range = document.createRange();
var startNode = document.getElementsByTagName("p").item(2);
var startOffset = 0;
range.setStart(startNode,startOffset);


Notes

If the startNode is a Node of type Text, Comment, or CDATASection, then startOffset is the number of characters from the start of startNode. For other Node types, startOffset is the number of child nodes between the start of the startNode.

Syntax

range.setStart(startNode, startOffset);

Standards information

Related specifications

DOM
Living Standard

Attributions