insertData: offset, arg
This method takes a string, splits the data
attribute's current contents at the
given offset
, then inserts the
string from the arg
parameter
between the two substrings.
The zero-based offset in the data
attribute where the insertion
is made.
The string to be inserted.
Raised if the offset
parameter is not a valid,
zero-based index into the data DOMString
.
Raised if the node is read-only.
// Insert data into a string boolean fCynical = true; // create a new Text object, and reference the CharacterData interface CharacterData ndCD = doc.createTextNode("The truth is out there."); ... // check for cynicism if (fCynical) { ndCD.insertData(12, " not"); } System.out.println(ndCD.getData( ));