How To

How to Add JavaScripts to a Web Page With Dreamweaver

Contributor
By eHow Contributing Writer
(4 Ratings)

With Dreamweaver 3, you can specify "behaviors" (something you want to have happen, such as a sound playing), and events (the "trigger" that launches the action, such as moving the mouse over an object) without writing JavaScript code. But you can also import pre-written JavaScript code and add it to your page in the same way that you add the included behaviors.

Difficulty: Challenging
Instructions

Things You'll Need:

    Importing a JavaScript Into Dreamweaver

  1. Step 1

    If you have a JavaScript you want to use, open the file where the JavaScript is located. If you're downloading a Dreamweaver extension file, use a file decompression program, such as WinZip or ZipIt, to extract the file.

  2. Step 2

    Locate and open the folder where the Dreamweaver program is installed (such as Programs). Find and open the Configuration folder, then the Actions folder.

  3. Step 3

    Paste or extract the JavaScript file into the Actions folder.

  4. Step 4

    Restart the Dreamweaver program and proceed to the next section.

  5. Using a Dreamweaver Behavior or Imported JavaScript

  6. Step 1

    Start the Dreamweaver program and open the page that the JavaScript or behavior will be added to.

  7. Step 2

    Open the Window menu and choose Behaviors, or press the F8 button. This opens the Behavior Inspector.

  8. Step 3

    Select the text or object that the behavior or JavaScript will be attached to. In the Behavior Inspector, choose the browser you are designing the page for. (Some behaviors can only be used with certain browsers.)

  9. Step 4

    Click on the Plus sign and choose the imported JavaScript or a Dreamweaver behavior (see Tips for more information about the behaviors). Dimmed behaviors cannot be used on your page; to get more behavior options, choose a more recent browser, such as Internet Explorer 5.

  10. Step 5

    Select the parameters for the behavior (any values the behavior needs to run) and click OK.

  11. Step 6

    Choose the event that triggers the behavior by clicking on the arrow button next to the behavior and selecting the desired event.

  12. Step 7

    Save the page, then test it by selecting Preview in Browser from the File menu and performing the event (such as double-clicking).

Tips & Warnings
  • Each behavior performs a different function. For example, the Play Sound behavior plays a sound when triggered by an event. Open the Dreamweaver help file and type "behavior" to learn more about the different behaviors included with Dreamweaver.
  • Events trigger behaviors. For example, when a user hovers the mouse over an image, a sound is played. The mouse-over is the event; the sound playing is the behavior. You can select from a variety of events, including double-click, mouse-over and mouse-down. For more information about available events, also see the Behaviors section of Dreamweaver's help file.
  • JavaScripts and behaviors don't work in many early browsers. Be sure to offer an alternate page for browsers that do not support JavaScript.

Post a Comment

Post a Comment
  • Have you done this? Click here to let us know.
I Did This

Related Ads

Internet
Virginia DeBolt,

Meet Virginia DeBolt eHow's Internet Expert.

Get Free Internet Newsletters

Copyright © 1999-2009 eHow, Inc. Use of this web site constitutes acceptance of the eHow Terms of Use and Privacy Policy.   en-US

Demand Media
eHow_eHow Technology and Electronics