DOMCharacterData methods

In addition to the methods it inherits from the DOMNode interface, the DOMCharacterData interface supports the following methods:

appendData(strData) 
Returns  No return value 
Description  Append strData to the end of the character data of the node. data then provides access to the concatenated result. Not implemented; see the example below for a workaround. 
Usage 
JScript  DOMCharacterData_object.appendData("strData");  
VBScript  DOMCharacterData_object.appendData "strData" 
Example 
// SoftQuad Script Language JSCRIPT:
// Assume DOMCharacterData object is
// in variable "cdnode".
// Substitute for 'cdnode.appendData("String");' 
Selection.SelectNodeContents(cdnode);
Selection.Collapse(0);
Selection.Text = "String";
 

deleteData(longOffset, longCount) 
Returns  No return value 
Description  Remove a range of characters starting at longOffset, and longCount in length, from the node. If the operation succeeds, data and length reflect the change. Not implemented; see example below for a workaround. 
Usage 
JScript  DOMCharacterData_object.deleteData(longOffset, longCount);  
VBScript  DOMCharacterData_object.deleteData longOffset, longCount" 
Example 
// SoftQuad Script Language JSCRIPT:
// Substitute for
// deleteData(Offset,Count)
// Assume var "cdnode" contains the
// DOMCharacterData node, and vars
// Offset and Count contain the
// desired arguments.
var Octr, Cctr;
Selection.SelectNodeContents(cdnode);
Selection.Collapse(1);
for (Octr=1; Octr<=Offset; Octr++) {
   Selection.MoveRight(0);
}
for (Cctr=1; Cctr<=Count; Cctr++) {
   Selection.MoveRight(1);
}
Selection.Cut();
 

insertData(longOffset, strData) 
Returns  No return value 
Description  Inserts strData at the specified longOffset. Not implemented; see the example below for a workaround. 
Usage 
JScript  DOMCharacterData_object.insertData(longOffset, "strData");  
VBScript  DOMCharacterData_object.insertData longOffset, "strData" 
Example 
// SoftQuad Script Language JSCRIPT:
// Substitute for
// insertData(Offset,"Data")
// Assume var "cdnode" contains the
// DOMCharacterData node, and vars
// Offset and Data contain the
// desired values.
var Octr;
Selection.SelectNodeContents(cdnode);
Selection.Collapse(1);
for (Octr=1; Octr<=Offset; Octr++) {
   Selection.MoveRight(0);
}
Selection.Text="Data";
 

replaceData(longOffset, longCount, strData)  
Returns  No return value 
Description  Replace the characters starting at longOffset, with the first longCount characters of strData. If the sum of longOffset and longCount exceeds length, then all characters to the end of the data are replaced. Not implemented; see the example below for a workaround. 
Usage 
JScript  DOMCharacterData_object.replaceData(longOffset, longCount, "strData");  
VBScript  DOMCharacterData_object.replaceData longOffset, longCount, "strData" 
 
// SoftQuad Script Language JSCRIPT:
// Substitute for
// replaceData(Offset,Count,"Data")
// Assume var "cdnode" contains the
// DOMCharacterData node, and vars
// Offset and Count contain the
// desired values.
var Octr, Cctr;
Selection.SelectNodeContents(cdnode);
Selection.Collapse(1);
for (Octr=1; Octr<=Offset; Octr++) {
   Selection.MoveRight(0);
}
for (Cctr=1; Cctr<=Count; Cctr++) {
   Selection.MoveRight(1);
}
Selection.Text="Data";
 

substringData(longOffset, longCount) 
Returns  String  
Description  Returns a range of data from the node, starting at longOffset, longCount in length. If the sum of longOffset and longCount exceeds the length, then all the characters to the end of the data are returned. 
Usage 
JScript  DOMCharacterData_object.substringData(longOffset, longCount);  
VBScript  DOMCharacterData_object.substringData(longOffset, longCount) 
Example 
// SoftQuad Script Language JSCRIPT:
var text = ActiveDocument.documentElement.firstChild;
Application.alert(text.substringData(1,3));
 


Right arrow
Next Topic
Left arrow
Previous Topic
Table of contents
Table of Contents

Copyright © SoftQuad Software Inc. 1999