User Guide
Selection functions 341
Returns
An array that contains two integers. The first integer is the byte offset for the beginning of the
selection; the second integer is the byte offset for the end of the selection. If the two numbers
are the same, the current selection is an insertion point.
dreamweaver.nodeExists()
Available
Dreamweaver 3.
Description
Determines whether the reference to the specified node is still good. Often when writing
extensions, you reference a node and then perform an operation that deletes it (such as setting
the
innerHTML or outerHTML properties of its parent). This function lets you confirm that the
node hasn’t been deleted before you attempt to reference any of its properties or methods. The
referenced node does not need to be in the current document.
Arguments
node
■ The node argument is the node that you want to check.
Returns
A Boolean value: true if the node exists; false otherwise.
Example
The following example gets the current node, locates a table within it, and later calls
dw.nodeExists() to see if the original node still exists:
function applyFormatToSelectedTable(){
// get current selection
var selObj = dw.getDocumentDOM().getSelectedNode();
alternateRows(dwscripts.findDOMObject("presetNames").selectedIndex,
findTable());
// restore original selection, if it still exists; if not, just select the
// table.
var selArr;
if (dw.nodeExists(selObj))
selArr = dom.nodeToOffsets(selObj);
000_DW_API_Print.book Page 341 Wednesday, July 20, 2005 11:58 AM