W3cubDocs

/Haxe JavaScript

Selection

package js.html

@:native("Selection") Available on js

Calling the Selection.toString() method returns the text contained in the selection, e.g.:

Documentation Selection by Mozilla Contributors, licensed under CC-BY-SA 2.5.

See:

Variables

read only anchorNode:Node

Returns the Node in which the selection begins.

read only anchorOffset:Int

Returns a number representing the offset of the selection's anchor within the anchorNode. If anchorNode is a text node, this is the number of characters within anchorNode preceding the anchor. If anchorNode is an element, this is the number of child nodes of the anchorNode preceding the anchor.

caretBidiLevel:Int

read only focusNode:Node

Returns the Node in which the selection ends.

read only focusOffset:Int

Returns a number representing the offset of the selection's anchor within the focusNode. If focusNode is a text node, this is the number of characters within focusNode preceding the focus. If focusNode is an element, this is the number of child nodes of the focusNode preceding the focus.

read only isCollapsed:Bool

Returns a Boolean indicating whether the selection's start and end points are at the same position.

read only rangeCount:Int

Returns the number of ranges in the selection.

Methods

addRange (range:Range):Void

Throws:

null DOMError

collapse (node:Node, offset:Int):Void

Throws:

null DOMError

collapseToEnd ():Void

Throws:

null DOMError

collapseToStart ():Void

Throws:

null DOMError

containsNode (node:Node, allowPartialContainment:Bool):Bool

Throws:

null DOMError

deleteFromDocument ():Void

Throws:

null DOMError

extend (node:Node, offset:Int):Void

Throws:

null DOMError

getRangeAt (index:Int):Range

Throws:

null DOMError

modify (alter:String, direction:String, granularity:String):Void

Throws:

null DOMError

removeAllRanges ():Void

Throws:

null DOMError

removeRange (range:Range):Void

Throws:

null DOMError

selectAllChildren (node:Node):Void

Throws:

null DOMError

© 2005–2018 Haxe Foundation
Licensed under a MIT license.
https://api.haxe.org/js/html/Selection.html