Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Design > Voices That Matter

This chapter is from the book

This chapter is from the book

Sharing Extensions

If your object or behavior is helpful to you, maybe it will be helpful to others. Of course, the more people you share with, the more your extension will need to be cleaned up, dressed up, and made reliable and understandable. If you're not sure what this means, take a look at the extensions that ship with Dreamweaver. They're well-documented; the code is bulletproofed; they have standardized, well-designed interfaces; and they're nicely packaged. None of this happens by accident.

Do You Want to Share?

First of all, you need to ask yourself whether you really want to share. If an object or behavior is probably going to be useful only to your personal workflow, client requirements, or current assignment; if your code is lacking many of the niceties that other people will expect; and if you don't have time to spare getting things in shape to share, you can stop reading right here, and just continue using your custom-made extensions yourself.

On the other hand, you might work in a group setting where all the Dreamweaver users in your office would benefit from your custom extension. Or, you might be a public-minded soul who thinks that the world-at-large can benefit from your brilliance, and you want to submit your extension to the Macromedia Exchange. If that's you, read on!


Bulletproofing means making sure that your extension will work under a variety of conditions without breaking. The more diverse circumstances your extension will be used in, the more bulletproof it should be.

How do you bulletproof? Read on.

Test the Inserted Code

No object or behavior is better than the code it inserts. Make sure that your code is worth inserting. Create sample Web pages using code that was inserted with your custom extension. Does the code work successfully across platforms? Does it work in different browsers? Macromedia recommends making sure that your code works in all the major version 4+ browsers and "fails gracefully" in version 3 browsers.

Test the Insertion Process

If there's not a dialog box with opportunities for user input, then the code should insert the same every time. If there is a dialog box, however, then consider the following:

  • What happens if the user leaves all values at their defaults and just clicks OK? Does Dreamweaver crash? Does garbage get inserted into the user's document?

  • What happens if the user enters unusual or wrong data in the dialog box?

  • What do you want to have happen in either of these circumstances? You can code the extension so that valid code gets entered no matter what, you can cause an alert message, or you can simply make the extension not insert code at all unless the user input meets certain criteria. It's up to you.


Macromedia recommends that you let the user enter whatever input he desires, as long as it's not going to actually "break" the page—in other words, a result is considered acceptable if the browser will simply ignore the incorrect or nonstandard code rather than generating JavaScript errors, crashing, or exhibiting any other noticeable problems. This is recommended because coding standards evolve—so what's nonsensical code today might be perfectly valid tomorrow—and because users don't like being boxed in by too-rigid requirements for code entry.

A good example of a well-bulletproofed insertion process is Macromedia's own table object. As a learning experience, open Dreamweaver and try using this object with strange dialog box entries. You'll find that the following are true:

  • Left to its defaults, the object inserts a valid table based on the last time the object was used.

  • Fields that correspond to optional table parameters can be left blank, with the result that the inserted code simply doesn't include those parameters.

  • The rows and columns fields, which must have certain values for the table code to function, will not accept invalid entries. Any non-numeric entry, or 0, will be replaced by a 1.

Test the Object/Behavior Itself

You already know that it works on your computer, with your version of Dreamweaver and your operating system. But ask yourself these questions:

  • Does it work with older versions of Dreamweaver?

  • Does it work on versions of Dreamweaver that are configured differently than yours?

  • Does it work on computers that are configured differently than yours?

  • Does it work on different platforms?

It may be that some of these things don't matter. If your extension needs to work only in your company, and if you only have PCs running Windows 2000 and Dreamweaver 4, then who cares if it runs correctly on Dreamweaver 2 on a Macintosh or Windows 95? Even though you might not need to fix a certain limitation, though, it's a good idea to be aware of it so that you can share intelligently.


Macromedia requests that all behaviors submitted to the Exchange include, as part of the defined function, the version of Dreamweaver that they are intended to work with. This information should be added as a comment to the defined function, like this:

function resizeBrowserWindow(width,height) { //v3.0

Exercise 22.13 Testing a Custom Behavior

This exercise uses the previously mentioned testing criteria to improve the Resize Window behavior we created earlier in this chapter. (If you don't have the complete code for this object, you can find it on the accompanying CD-ROM.)

  1. Test the inserted code. The inserted code, in this case, is a JavaScript function that resizes the current browser window. How robust is this code?

  2. According to the O'Reilly online JavaScript reference provided with Dreamweaver, this function should work in Netscape 4+ and in Internet Explorer (see Figure 22.24).

    Figure 22.24 Dreamweaver's Reference window showing the O'Reilly information for the resizeTo() function.

    If you want to be thorough, test this by actually trying the code in as many different browser/platform configurations as you have access to. For purposes of this exercise, assume that the O'Reilly information is correct.

  3. Adjust the behavior accordingly. You can't do anything about the script's failure to work in Netscape 3. But you can ask yourself if it will "fail gracefully" in that browser.

  4. If you try the script in Netscape 3, you'll see that the browser simply ignores it—no harm, no foul. This qualifies as failing gracefully, so there's no adjustment needed.

  5. See what happens when the behavior is used with default values. As your behavior is currently written, there are no default values for the width and height arguments. What will happen if the user tries to enter the behavior that way? Try it, and you'll see that the code is inserted incompletely:

    <a href="#" onMouseUp="resizeBrowserWindow(,)"> click </a> 

    The simplest way to avoid this problem is to put default values into the dialog box. Do this by altering the form code so that it looks like this:

    	<tr valign="baseline">
    		<td align="right" nowrap>New width:</td>
    		<td align="left">
    			<input type="text" name="width" size="8" value="300">
    	<tr valign="baseline">
    		<td align="right" nowrap>New height:</td>
    		<td align="left">
    			<input type="text" name="height" size="8" value="300">

    Do this and then try out the revised behavior. The dialog box should always come up with the default values in place.

  6. Try the behavior with invalid input. Try the resize behavior and see what it does if you enter non-numeric data, or zeroes, or empty fields, as shown in Figure 22.25. What happens?

  7. You already know that leaving the fields empty is a dangerous proposition. Entering zeroes is equally dangerous. Entering non-numeric data will generate JavaScript errors in Internet Explorer and is definitely a bad idea. Perhaps you should fix this problem.

    Figure 22.25 Non-numeric data, or zeroes, entered into the Resize Window behavior dialog box, resulting in invalid arguments passed to the function in the user's document.

  8. Rewrite the behavior to disallow invalid input. Rewrite the applyBehavior() function so that the form fields are each validated before the function call is inserted. Valid data should be positive integers only; you also might want to consider extremely large numbers invalid. If no valid data is present, make the behavior resort to its default values.

  9. Depending on your scripting style, you may choose to implement this error-checking in any number of ways. Your code may end up looking like this:

    function applyBehavior() {
    var width=document.theForm.width.value;
    var height=document.theForm.height.value;
    if (width=="" || width<1 || width>2000 || parseInt(width) != width) {
    if (height=="" || height<1 || height>2000 || parseInt(height) != height) {
    return "resizeBrowserWindow(" + width + "," + height + ")";
  10. Try out the revised behavior. What happens now when you try to break the behavior by entering some bizarre data (or nothing at all) in the dialog box? It should default to 300x300, or whatever default width and height you decided on. Your behavior is now bulletproof—or, at least, more bulletproof than it was before.

Design: Testing for Usability

Although you can test for technical errors, the best people to test for design and usability errors are other people—preferably people who have no knowledge of your development process and who are not themselves software developers. Beta testers may indeed find ways to break your extension—in which case, you're back to bulletproofing.

More likely, though, they'll find problems in your design. Is the object or behavior's name self-explanatory, as it appears in menu listings and ToolTips? If it's an object, is its icon communicative and intuitive? If it has a dialog box, is the dialog box attractive and intuitive to use? Does the whole interface blend in well with the Dreamweaver main interface? Is the desired purpose of the extension clear? Does the extension do what users think it's going to do? Is it lacking some key functionality? Do they perceive it as potentially useful?

If the answer to any of these questions is a resounding "No!," you have some redesigning to do.


Macromedia offers a set of UI guidelines to help you create intuitive, functional interfaces that blend in well with the rest of the Dreamweaver interface. To see these guidelines, go to the Macromedia Exchange for Dreamweaver page ( and click the Site Help topic Macromedia Approved Extensions. The code for this chapter has been written to follow these guidelines as much as possible.


So, you think you're going to remember what this extension is supposed to accomplish six months from now or a year from now? Probably not. And if you can't remember it, obviously no one else can, either. Always, always, always document what you're doing—for your benefit and everyone else's.


Always comment your code. Always. Macromedia recommends it—you know it's the right thing to do. Commenting will help you troubleshoot and update the object or behavior in the future. It also will help others learn from your process. (The examples shown so far in this chapter haven't been commented so that you could better examine the code for learning purposes. In the real world, they would be full of comment lines.)

Online Help

According to Macromedia, every extension should have some sort of online help, accessible from the extension's dialog box. Dreamweaver is configured to make adding help files easy for you.

  • Help in the dialog box. If your object or behavior is so simple that a sentence or two is all the explanation that anybody will ever need, you can put that in the dialog box. Macromedia recommends that you add a table cell at the bottom of the layout, with the cell background color set to #D3D3D3. (Figure 22.26 shows an example of this.)

  • Help in a help file. If your extension needs more explanation than a sentence or two, put the information in an HTML file. Store the HTML file in a new, personalized folder in the Configuration/Shared folder. (Figure 22.27 shows an example of this.) Place a Help button in the extension's dialog box, linked to that file.

Figure 22.26 The Contact Info object, with a brief help statement added to the bottom. The top view, taken from Dreamweaver layout view, shows the additional table cell used for formatting.

Figure 22.27 The Resize Window behavior dialog box, with a Help button. Clicking the button tells the behavior file to call on a help file (ResizeWindowHelp.html) in a custom folder (Development) in the Configuration/Shared folder.

Exercise 22.14 Adding Online Help to Your Behavior

In this exercise, you'll refine your Resize Window behavior by adding a Help button to the dialog box and linking it to an HTML file in the Shared folder.

  1. Create a folder in the Shared folder to store your help documents.

  2. Using Explorer or the Finder, open the Configuration folder and the Shared folder inside it. Create a new folder in here; call it Development. Figure 22.28 shows how the folder structure should look.

    Figure 22.28 The folder structure of the Configuration/Shared folder with the new Development folder created inside.

  3. Create the HTML file. Your help page should include information on what the behavior does, every field and what content it can accept, and any other information you think users will find helpful.

  4. You can create your own HTML file or use the file ResizeWindowHelp.html, located on the CD. Figure 22.29 shows an example of what a typical help file might look like.

    Save the file as ResizeWindowHelp.html in the Configuration/Shared/ Development folder.

  5. Add the Help button to your behavior's dialog box. Open the behavior file ResizeWindow.js in your text editor. Add this framework code for the function:

  6. function displayHelp() {

    The displayHelp() function is part of the Dreamweaver API; when present, it is called automatically, so you don't need to call it.

    When you've done this, reload extensions and try out your revised behavior. When the dialog box comes up, there should be a Help button in place, like the one shown in Figure 22.27. (Of course, because the function is empty so far, clicking the button won't get you anywhere.)

    Figure 22.29 The Resize Window behavior's help file, as it will appear when viewed in a browser.

  7. Link the Help button to your help file.

  8. The standard thing you do with Help buttons is link them to help files. This is done with a function that is part of the Dreamweaver API, dw.browseDocument(). This function takes an absolute URL as its argument. If your help file is located on the Web—maybe on your own company Web site so that users have to come to you to get the latest and greatest help—just enter an absolute Web address as the argument. In this case, the help function would look like this:

    function displayHelp() {

    Because your help file is going to end up on the user's hard drive, the code needs to return an absolute pathname to that file. Luckily, the Dreamweaver API function, dw.getConfigurationPath(), returns the absolute address to the Configuration folder. All you have to do after getting that information is figure out the path to the help file relative to this root and concatenate the two together. So, the code you should enter looks like this:

    function displayHelp() {	
    var myURL = dw.getConfigurationPath();
    myURL += "/Shared/Development/ResizeWindowHelp.html";

    Enter this code. Then, reload extensions and try it out. If the proper help page doesn't load, double-check the code and tweak it until it does. Make sure that you've entered the path from the Configuration folder to your help file exactly—depending on how you've named your files and folders, your path may differ from the one shown here.


The two API functions introduced here are both methods of the Dreamweaver object. Methods of this object can be written as dreamweaver.functionName() or dw.functionName(). The second choice offers fewer opportunities for typos.


How are you going to get your lovely object or behavior into Configuration folders everywhere? Read on for instructions.

Packaging for the Extension Manager

The Extension Manager is becoming the standard method of painless extension installation. Therefore, this is the most accessible way to share your extensions.

Lucky for us, the Extension Manager not only installs extensions, but it also packages them up neatly into special installation files. The process is even relatively painless. The steps are listed here:

  1. Put all the required files (help files, HTML files, JS files, and GIF icons) in one folder, outside the Configuration folder.

  2. Create an installation file. This is an XML document with the filename extension .mxi that contains all the instructions needed for installation: where the files should be stored, what versions of Dreamweaver and what platforms the extension requires, the author's name, the type of extension, and a description. The formatting required is very exact. The best approach for beginners is to start from the samples included with the Extension Manager. These files include a blank file (blank.mxi) to use as a template and a sample file (sample.mxi) filled in with information for a simple object.

  3. Launch the Extension Manager, and go to File/Package Extension.

See Figure 22.30 for a sample folder containing all the proper files to package the Contact Info file. This last exercise takes you through all the steps to create this folder.

Figure 22.30 The assembled elements of the Contact Info object, all ready for packaging.

Exercise 22.15 Packaging an Extension

In this exercise, you'll pack up the Contact Info object for sharing with the world.

  1. Copy all needed files into one folder. Somewhere on your hard drive, outside the Configuration folder, create a new folder. Name it whatever you like and will remember (something like Contact Info Files, maybe).

    Find all the files that make up the behavior, and copy them there. Files that you should include are listed here:

    • Contact Info.html
    • Contact Info.js
    • Contact Info.gif
  2. Open the blank.mxi file to use in creating the installation file. Duplicate it and save it in your collection folder as ContactInfo.mxi.

    On your hard drive, find the Extension Manager application folder. Inside that folder, find the Dreamweaver/Samples folder. Inside there, you should see blank.mxi. (Figure 22.31 shows where to find these items.)

    Figure 22.31 The Extension Manager application folder structure, showing sample.mxi and blank.mxi.

    Afteryou've made the duplicate file, open it in your text editor.


    You can download a PDF file containing detailed instructions for creating installation files from the Macromedia Web site. Go to the Macromedia Exchange for Dreamweaver page (, and click the Site Help topic Macromedia Approved Extensions.

  3. Fill in the blanks with the information for your object. The blank file has all the framework you need. By examining the sample file, you can get an idea how it should be formatted. For your extension, fill in the blanks until your code looks like that shown in Figure 22.32.

    A few tips about filling in the code:

    • For the author name. Enter your name (John Smith, Web Genius has been entered here—there's no law against being fanciful).

    • For the filenames. Enter the complete path from the Dreamweaver application folder root, as shown. If you want your extension to create any new folders in existing folders, enter them as part of the path (SmithStuff has been entered here to create a new folder within the Objects folder). If the object included any added folders within the Shared folder, they would have been added in the same way.

    • For the version number. Your extension, like any other piece of software, gets its own version number. Start with 1.0, and increment the number if you later revise the extension.

    Figure 22.32 The complete code for ContactInfo.mxi. Information that has been added to the framework from blank.mxi is highlighted.

  4. Package everything together with the Extension Manager. Launch the Extension Manager. Go to File/Package Extension.

    For the name of your extension, choose something descriptive that obeys the standard naming conventions (no empty spaces, no more than 20 characters, no special characters). Make sure that you leave the .mxp extension in place.

    When you're asked to choose a file, choose ContactInto.mxi.

    If there aren't any problems, the Manager will generate an extension file in the same folder as the .mxi file. If there are problems, you'll get an error report. Most often, these are problems with the .mxi file. If there are, go back to your text editor, fix the reported errors and try again.

    Figure 22.33 shows how this process will look in the Extension Manager.

    Figure 22.33 The steps through the packaging process, as they appear in the Extension Manager.

  5. Use the Extension Manager to install your new extension. Quit Dreamweaver, if it's running. In the Extension Manager, go to File/Install. When the dialog box comes up, browse to ContactInfo.mxp.

    If everything's hunky dory, you should get an alert message telling you that the extension was installed successfully. Your custom extension should also now appear in the Extension Manager window, as shown in Figure 22.34.

  6. Launch Dreamweaver and check that everything installed correctly. If all went as smoothly as reported, a new category should appear in the Objects panel, named SmithStuff or whatever you called your custom folder. Your object should be the only thing in that category. Check the ToolTip; try inserting it. Then pat yourself on the back—you did it!

Figure 22.34 The Extension Manager window, showing the installed Contact Info object.

Submitting to the Macromedia Exchange

The ultimate in sharing is submitting your extension file to the Macromedia Exchange. When you have the .mxp file, the procedure is simple: Go to the Macromedia Exchange Web site and click the Submit button at the top of the page. Then follow the instructions to submit (see Figure 22.35).

Figure 22.35 The Macromedia Exchange home page with the Submit button.

When you have submitted an extension, Macromedia engineers will run it through a series of tests. One of three things will happen:

  • If it fails, it gets returned to you with comments.

  • If it passes the basic tests, it gets put on the Web site as a Basic, or unapproved, extension.

  • If it also passes the more comprehensive tests, it becomes a Macromedia Approved Extension.

To learn more about the testing process and how to get your extensions accepted and approved, visit the Web site and click any one of the Site Help FAQ topics. This will take you to an extensive categorized list of questions and answers.

Peachpit Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from Peachpit and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about Peachpit products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites; develop new products and services; conduct educational research; and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by Adobe Press. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive:

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020