Range Class
https://dom.spec.whatwg.org/#interface-range
public sealed class Range : AbstractRange- Inheritance
AbstractRangeRange
Constructors
| Name | Description |
|---|---|
| Range() | Creates a collapsed range at the start of the current global document. |
Range()
Range.csCreates a collapsed range at the start of the current global document.
public Range()Properties
| Name | Description |
|---|---|
| CommonAncestorContainer | https://dom.spec.whatwg.org/#dom-range-commonancestorcontainer |
CommonAncestorContainer
Range.cshttps://dom.spec.whatwg.org/#dom-range-commonancestorcontainer
public Node CommonAncestorContainer { get; }Methods
| Name | Description |
|---|---|
| CloneContents() | Returns a document fragment containing a copy of the contents of the range. |
| CloneRange() | Returns a new range with the same boundary points as this range. |
| Collapse(bool) | Collapses the range to its start when toStart is true, or to its end otherwise. |
| CompareBoundaryPoints(ushort, Range) | https://dom.spec.whatwg.org/#dom-range-compareboundarypoints |
| ComparePoint(Node, uint) | https://dom.spec.whatwg.org/#dom-range-comparepoint |
| CreateContextualFragment(TrustedHtml) | https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-range-createcontextualfragment |
| CreateContextualFragment(string) | https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-range-createcontextualfragment |
| DeleteContents() | https://dom.spec.whatwg.org/#dom-range-deletecontents |
| Detach() | Does nothing (https://dom.spec.whatwg.org/#dom-range-detach). |
| ExtractContents() | Removes the contents of the range from the tree and returns them in a document fragment. |
| GetBoundingClientRect() | Returns the bounding box of the boxes of the range (https://drafts.csswg.org/cssom-view/#dom-range-getboundingclientrect): see Range.GetClientRects and Element.GetBoundingClientRect. |
| GetClientRects() | Returns the boxes of the range (https://drafts.csswg.org/cssom-view/#dom-range-getclientrects), in the coordinates of the viewport: the boxes of the elements contained in the range whose parent is not (see Element.GetClientRects), and for each text node selected or partially selected, the rectangle of the selected characters of each of its text fragments (their advance along the inline axis, the ascent and descent of the font along the block axis; a collapsed range in a text gives a rectangle without width), with the transforms applied. |
| InsertNode(Node) | Inserts the given node into the tree at the start of the range. |
| IntersectsNode(Node) | https://dom.spec.whatwg.org/#dom-range-intersectsnode |
| IsPointInRange(Node, uint) | https://dom.spec.whatwg.org/#dom-range-ispointinrange |
| SelectNode(Node) | https://dom.spec.whatwg.org/#concept-range-select |
| SelectNodeContents(Node) | Sets the range to contain all the children of the given node. |
| SetEnd(Node, uint) | Sets the end of the range to the given node and offset. |
| SetEndAfter(Node) | Sets the end of the range to the position just after the given node. |
| SetEndBefore(Node) | Sets the end of the range to the position just before the given node. |
| SetStart(Node, uint) | Sets the start of the range to the given node and offset. |
| SetStartAfter(Node) | Sets the start of the range to the position just after the given node. |
| SetStartBefore(Node) | Sets the start of the range to the position just before the given node. |
| SurroundContents(Node) | https://dom.spec.whatwg.org/#dom-range-surroundcontents |
| ToString() | The stringification behavior (https://dom.spec.whatwg.org/#dom-range-stringifier). |
CloneContents()
Range.csReturns a document fragment containing a copy of the contents of the range.
public DocumentFragment CloneContents()CloneRange()
Range.csReturns a new range with the same boundary points as this range.
public Range CloneRange()Collapse(bool)
Range.csCollapses the range to its start when toStart is true, or to its end otherwise.
CompareBoundaryPoints(ushort, Range)
Range.csComparePoint(Node, uint)
Range.csCreateContextualFragment overloads
CreateContextualFragment(TrustedHtml)
DynamicMarkup.cshttps://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-range-createcontextualfragment
public DocumentFragment CreateContextualFragment(TrustedHtml fragment)CreateContextualFragment(string)
DynamicMarkup.cshttps://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-range-createcontextualfragment
public DocumentFragment CreateContextualFragment(string fragment)Parameters
fragmentstring
Returns
Exceptions
TypeErrorException- Trusted Types are enforced and the default policy did not convert the value.
See also
DeleteContents()
Range.cshttps://dom.spec.whatwg.org/#dom-range-deletecontents
public void DeleteContents()Detach()
Range.csDoes nothing (https://dom.spec.whatwg.org/#dom-range-detach).
public void Detach()ExtractContents()
Range.csRemoves the contents of the range from the tree and returns them in a document fragment.
public DocumentFragment ExtractContents()GetBoundingClientRect()
CssomView.csReturns the bounding box of the boxes of the range (https://drafts.csswg.org/cssom-view/#dom-range-getboundingclientrect): see Range.GetClientRects and Element.GetBoundingClientRect.
public DomRect GetBoundingClientRect()GetClientRects()
CssomView.csReturns the boxes of the range (https://drafts.csswg.org/cssom-view/#dom-range-getclientrects), in the coordinates of the viewport: the boxes of the elements contained in the range whose parent is not (see Element.GetClientRects), and for each text node selected or partially selected, the rectangle of the selected characters of each of its text fragments (their advance along the inline axis, the ascent and descent of the font along the block axis; a collapsed range in a text gives a rectangle without width), with the transforms applied.
public DomRectList GetClientRects()InsertNode(Node)
Range.csInserts the given node into the tree at the start of the range.
IntersectsNode(Node)
Range.cshttps://dom.spec.whatwg.org/#dom-range-intersectsnode
IsPointInRange(Node, uint)
Range.csSelectNode(Node)
Range.cshttps://dom.spec.whatwg.org/#concept-range-select
SelectNodeContents(Node)
Range.csSets the range to contain all the children of the given node.
SetEnd(Node, uint)
Range.csSetEndAfter(Node)
Range.csSets the end of the range to the position just after the given node.
SetEndBefore(Node)
Range.csSets the end of the range to the position just before the given node.
SetStart(Node, uint)
Range.csSetStartAfter(Node)
Range.csSets the start of the range to the position just after the given node.
SetStartBefore(Node)
Range.csSets the start of the range to the position just before the given node.
SurroundContents(Node)
Range.cshttps://dom.spec.whatwg.org/#dom-range-surroundcontents
ToString()
Range.csConstants
| Name | Description |
|---|---|
| EndToEnd | Compares the end of the given range to the end of this range. |
| EndToStart | Compares the start of the given range to the end of this range. |
| StartToEnd | Compares the end of the given range to the start of this range. |
| StartToStart | Compares the start of the given range to the start of this range. |
EndToEnd
Compares the end of the given range to the end of this range.
public const ushort EndToEnd = 2EndToStart
Compares the start of the given range to the end of this range.
public const ushort EndToStart = 3StartToEnd
Compares the end of the given range to the start of this range.
public const ushort StartToEnd = 1StartToStart
Compares the start of the given range to the start of this range.
public const ushort StartToStart = 0