SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 1717 | Next

Joseph W. Lowery

"Dreamweaver CS3 Bible"


Selecting objects
By comparison, you have far fewer hoops to jump through to reference a selected object: You only have to
get its outerHTML property, as shown in Listing 33-2.
1021
Customizing Dreamweaver 33
LISTING 33-2
Getting a Selected Object
function replicate() {
var theDom = dreamweaver.getDocumentDOM(???document???);
var offsets = dreamweaver.getSelection();
var selObj =
dreamweaver.offsetsToNode(offsets[0],offsets[1]);
if (selObj.nodeType == Node.TEXT_NODE) {
helpMe2();
window.close();
return;
}
var theCode = selObj.outerHTML;
}
Listing 33-2 also includes a small error routine that checks whether the user??™s selection is text
(selObj.nodeType == Node.TEXT_NODE) and, if so, uses helpMe2() (a custom function that must
be defined elsewhere in the script) to put up an advisory and then closes the window to enable the user to
reselect.
Using a command as an object
Commands offer a tremendous range of power and can perform actions not available to behaviors or
objects. To take advantage of this power with a point-and-click interface, it??™s best to disguise the command
as an object. As an object, the command appears in both the Insert bar and the Insert menu.
A Dreamweaver object usually consists of two files: an HTML file for the code and a GIF image for the button,
all in the Dreamweaver 9\Configuration\Objects\Category folder.


Pages:
1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729