Visit Mozilla.org

DOM:range.setStart

From MDC

« Gecko DOM Reference

Contents

[edit] Summary

Sets the start position of a Range.

[edit] Syntax

range.setStart(startNode, startOffset);
startNode 
The Node to start the Range
startOffset 
An integer greater than or equal to zero representing the offset for the start of the Range from the start of startNode.

[edit] Example

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

[edit] 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.

Setting the start point below (further down in the document) than the end point will throw an NS_ERROR_ILLEGAL_VALUE exception.

[edit] Specification

DOM Level 2 Range: Range.setStart