Specifications
371
CHAPTER 31
The Dreamweaver JavaScript API
The Macromedia Dreamweaver MX JavaScript API provides an extensive set of tools that are
useful to extension developers. In addition to the standards-based Document Object Model
(DOM) methods that are described in “The Dreamweaver Document Object Model” on page
41, Dreamweaver provides extension developers with more than 600 JavaScript functions that
encapsulate the kinds of tasks that users perform when creating or editing a document in
Dreamweaver. Almost any task that the user can accomplish with the menus, floating panels,
Property inspectors, Site panel, or Document window can also be done using JavaScript.
Many of the JavaScript API functions require that you specify which document you are working
on by getting the appropriate
dom. The most commonly used function for getting a document
object is
dreamweaver.getDocumentDOM(), because it gets the dom of the current user
document
. Other Dreamweaver functions can also return the document dom. For descriptions of
dreamweaver.getDocumentDOM(), dreamweaver.newDocumentDOM() and other functions that
return a document
dom, see “File manipulation functions” on page 447.
Note: In Dreamweaver 4 and later, dw can be used interchageably with dreamweaver when you write code, so all
dreamweaver methods can be referred to either as dreamweaver.functionName() or dw.functionName().
Understanding the objects in the API
Each time you call a JavaScript API method, it returns information from one of the following
three objects:
• An object that represents the current document, another open document, or a document on
disk
• The site object
• The dreamweaver object
Functions that work with the current document, another open document, or a document on disk
are methods of the
DOM object. Methods that work directly with DOM objects are listed as
dom.functionName(). To work with DOM methods, you must first get the DOM of a
document (see “dreamweaver.getDocumentDOM()” on page 453) and call the functions as
methods of that DOM. Dreamweaver DOM objects have all the properties and methods of a
document object, as described in “The Dreamweaver Document Object Model” on page 41.
Functions that refer to the Site panel or a selection in the Site panel are methods of the
site
object. For example,
site.put(remoteSite) puts the currently selected files from the Site panel
into the remote site.