Help Center

Local Navigation

Object: Text

Availability

BlackBerry® Device Software version 4.6 or later

Extends

CharacterData

The Text object represents the textual content of an element or attribute. If an element contains no child elements, any text is contained in a single text node in the DOM.

Although it is possible to place multiple text objects are adjacent to one another in a document, adjacent text nodes have no meaning in a document. Hence, using Text.splitText() has no visual effect on the document unless one of the nodes is wrapped by an element.

Text methods

Method name

Description

Availability

splitText()

Breaks the node into two nodes at the specified offset location.

4.6 or later

Method: Text.splitText()

Availability

BlackBerry® Device Software version 4.6 or later

The splitText() method breaks the node into two nodes at the specified offset location.

Syntax

Text.splitText( offset )

Parameters

Parameter

Type

Description

offset

long

The offset position at which to split the text.

Return values

Returns the second half of the text as a new Text node, which is automatically added to the DOM tree adjacent to the original Text node.

Exceptions

Exception

Description

INDEX_SIZE_ERR

This error is thrown if offset is negative, or is greater than the number of 16-bit units in the data.

NO_MODIFICATION_ALLOWED_ERR

This error is thrown if the Node is read only.

Next topic: Object: TextEvent

Was this information helpful? Send us your comments.