< Day Day Up > |
Selection functions get and set the selection in open documents. For information on getting or setting the selection in the Site panel, see "Site functions" on page 760. dom.getSelectedNode()Availability Dreamweaver 3. Description Gets the selected node. Using this function is equivalent to calling the dom.getSelection() function and passing the return value to the dom.offsetsToNode() function. Arguments None. Returns The tag, text, or comment object that completely contains the specified range of characters. dom.getSelection()Availability Dreamweaver 3. Description Gets the selection, which is expressed as character offsets into the document's source code. Arguments {bAllowMultiple}
Returns For simple selections, an array that contains two integers. The first integer is the character offset of the opening of the selection. The second integer is the character offset at the closing of the selection. If the two numbers are the same, the current selection is an insertion point. For complex selections (multiple table cells, multiple layers, or multiple image map hotspots), an array that contains 2n integers, where n is the number of selected items. The first integer in each pair is the character offset of the opening of the selection (including the opening TD, DIV, SPAN, LAYER, ILAYER, or MAP tag); the second integer in each pair is the character offset of the closing of the selection (including the closing TD, DIV, SPAN, LAYER, ILAYER, or MAP tag). If multiple table rows are selected, the offsets of each cell in each row return. The selection never includes the tr tags. dom.nodeToOffsets()Availability Dreamweaver 3. Description Gets the position of a specific node in the DOM tree, which is expressed as character offsets into the document's source code. It is valid for any document on a local drive. Arguments node
Returns An array that contains two integers. The first integer is the character offset of the beginning of the tag, text, or comment. The second integer is the character offset of the end of the node, from the beginning of the HTML document. Example The following code selects the first image object in the current document: var theDOM = dw.getDocumentDOM(); var theImg = theDOM.images[0]; var offsets = theDom.nodeToOffsets(theImg); theDom.setSelection(offsets[0], offsets[1]); dom.offsetsToNode()Availability Dreamweaver 3. Description Gets the object in the DOM tree that completely contains the range of characters between the specified opening and closing points. It is valid for any document on a local drive. Arguments offsetBegin, offsetEnd
Returns The tag, text, or comment object that completely contains the specified range of characters. Example The following code displays an alert if the selection is an image: var offsets = dom.getSelection(); var theSelection = dreamweaver.offsetsToNode(offsets[0], offsets[1]); if (theSelection.nodeType == Node.ELEMENT_NODE && theSelection.tagName == 'IMG'){ alert('The current selection is an image.'); } dom.selectAll()Availability Dreamweaver 3. Description Performs a Select All operation. NOTE In most cases, this function selects all the content in the active document. In some cases (for example, when the insertion point is inside a table), it selects only part of the active document. To set the selection to the entire document, use dom.setSelection(). Arguments None. Returns Nothing. dom.setSelectedNode()Availability Dreamweaver 3. Description Sets the selected node. This function is equivalent to calling the dom.nodeToOffsets() function and passing the return value to the dom.setSelection() function. Arguments node, {bSelectInside}, {bJumpToNode}
Returns Nothing. dom.setSelection()Availability Dreamweaver 3. Description Sets the selection in the document. Arguments offsetBegin, offsetEnd
Returns Nothing. dreamweaver.getSelection() (deprecated)Availability Dreamweaver 2; deprecated in 3. See "dom.getSelection()" on page 841. Description Gets the selection in the current document, which is expressed as byte offsets into the document's source code. Arguments None. 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
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); else selArr = dom.nodeToOffsets(findTable()); dom.setSelection(selArr[0],selArr[1]); } dreamweaver.nodeToOffsets() (deprecated)Availability Dreamweaver 2; deprecated in 3 in favor of "dom.nodeToOffsets()" on page 841. Description Gets the position of a specific node in the DOM tree, which is expressed as byte offsets into the document's source code. Arguments node
Returns An array that contains two integers. The first integer is the byte offset for the opening of the tag, text, or comment; the second integer is the byte offset for the closing of the node. dreamweaver.offsetsToNode() (deprecated)Availability Dreamweaver 2; deprecated in 3 in favor of "dom.offsetsToNode()" on page 842. Description Gets the object in the DOM tree that completely contains the range of characters between the specified opening and closing points. Arguments offsetBegin, offsetEnd
Returns The tag, text, or comment object that completely contains the specified range of characters. dreamweaver.selectAll()Availability Dreamweaver 3. Description Performs a Select All operation in the active document window, the Site panel or, on the Macintosh, the text field that has focus in a dialog box or floating panel. NOTE If the operation takes place in the active document, it usually selects all the content in the active document. In some cases (for example, when the insertion point is inside a table), however, it selects only part of the active document. To set the selection to the entire document, use the dom.setSelection() function. Arguments None. Returns Nothing. Enabler See "dreamweaver.canSelectAll()" on page 1077. dreamweaver.setSelection() (deprecated)Availability Dreamweaver 2; deprecated in 3 in favor of "dom.setSelection()" on page 844. Description Sets the selection in the current document. This function can move the selection only within the current document; it cannot change the focus to a different document. Arguments offsetBegin, offsetEnd
Returns Nothing. |
< Day Day Up > |