Extension APIs

The extension APIs provide you with the functions that Dreamweaver calls to implement each type of extension. You must write the bodies of these functions as described for each extension type and specify the return values that Dreamweaver expects.

If you are a developer who wants to work directly in the C programming language, there is a C extensibility API that lets you create dynamic link libraries (DLLs). The functionality that is provided in these APIs wraps your C DLLs in JavaScript so that your extension can work seamlessly in Dreamweaver.

The documentation of extension APIs outlines what each function does, when Dreamweaver calls it, and what value Dreamweaver expects it to return.

See the Dreamweaver API Reference for information about the Utility API and the JavaScript API, which provide functions that you can use to perform specific tasks in your extensions.

How Dreamweaver processes JavaScript in extensions

Dreamweaver checks the Configuration/extension_type folder during startup. If it encounters an extension file within the folder, Dreamweaver processes the JavaScript by completing the following steps:

  • Compiling everything between the beginning and ending SCRIPT tags

  • Executing any code within SCRIPT tags that is not part of a function declaration

    Note: This procedure is necessary during startup because some extensions might require global variables to initialize.

Dreamweaver performs the following actions for any external JavaScript files that are specified in the SRC attributes of SCRIPT tags:

  • Reads in the file

  • Compiles the code

  • Executes the procedures

 If any JavaScript code in your extension file contains the string ", the JavaScript interpreter reads the string as an ending script tag and reports an unterminated string literal error. To avoid this problem, break the string into pieces and concatenate them like this: "<' + '/SCRIPT>".

Dreamweaver executes code in the onLoad event handler (if one appears in the body tag) when the user selects the command or action from a menu for the Command and Behavior action extension types.

Dreamweaver executes code in the onLoad event handler in the body tag if the body of the document contains a form for object extensions.

Dreamweaver ignores the onLoad handler on the body tag in the following extensions:

  • Data translator

  • Property inspector

  • Floating panel

For all extensions, Dreamweaver executes code in other event handlers (for example, onBlur="alert('This is a required field.')") when the user interacts with the form fields to which they are attached.

Dreamweaver supports the use of event handlers within links. Event handlers in links must use syntax, as shown in the following example:

 <a href=”#” onMouseDown=alert(‘hi’)>link text</a>

Plug-ins (set to play at all times) are supported in the BODY of extensions. The document.write() statement, Java applets, and Microsoft ActiveX controls are not supported in extensions.

Displaying Help

The displayHelp() function, which is part of several extension APIs, causes Dreamweaver to do the following two things when you include it in your extension:

  • Add a Help button to the interface.

  • Call displayHelp() when the user clicks the Help button.

You must write the body of the displayHelp() function to display Help. How you code the displayHelp() function determines how your extension displays Help. You can call the dreamweaver.browseDocument() function to open a file in a browser or devise a custom way to display Help such as displaying messages in another absolutely positioned element in alert boxes.

The following example uses the displayHelp() function to display Help by calling dreamweaver.browseDocument():

 // The following instance of displayHelp() opens a browser to display a file 
// that explains how to use the extension. 
function displayHelp() { 
 
    var myHelpFile = dw.getConfigurationPath() + "ExtensionsHelp/myExtHelp.htm"; 
    dw.browseDocument(myHelpFile); 
}

 Adobe

Get help faster and easier

New user?