Chapter 3 DynaScript Predefined Objects
The DOMText
object inherits
all the methods of the DOMCharacterData
object, but
it also has one of its own methods, which is discussed here.
DOMText.splitText( offset )
Breaks this text node into two text nodes at the specified offset, keeping both in the tree as siblings. offset is the point where the text is to be split, starting from 0.
After the split, this DOMText
object contains
the content up to the offset point. The new DOMText
node,
added as the next sibling of this node, contains the content at
or after the offset point.
The new added DOMText
node.
This script takes an element that has a single text node as child (holding a street address), and adds text to the end of that node by splitting the text and then normalizing:
streetText = streetElement.firstChild;
streetText.splitText(stText.length );
streetElement.lastChild.data = " -- now moved";
streetElement.normalize();
Copyright © 1999 Sybase, Inc. All rights reserved. |
![]() |