Operation Manual

331
USING DREAMWEAVER
Adding JavaScript behaviors
Last updated 3/28/2012
Download and install third-party behaviors
Many extensions are available on the Exchange for Dreamweaver website
(
www.adobe.com/go/dreamweaver_exchange).
1 Choose Window > Behaviors and select Get More Behaviors from the Add Behavior menu.
Your primary browser opens, and the Exchange site appears.
2 Browse or search for packages.
3 Download and install the extension package you want.
For more information, see “Add and manage extensions in Dreamweaver” on page 33.
Applying built-in JavaScript behaviors
Using built-in behaviors
The behaviors included with Dreamweaver have been written to work in modern browsers. The behaviors fail silently
in older browsers.
Note: The Dreamweaver actions have been carefully written to work in as many browsers as possible. If you remove code
from a Dreamweaver action by hand, or replace it with your own code, you may lose cross-browser compatibility.
Although the Dreamweaver actions were written to maximize cross-browser compatibility, some browsers do not
support JavaScript at all, and many people who browse the web keep JavaScript turned off in their browsers. For best
cross-platform results, provide alternative interfaces enclosed in
<noscript> tags so that people without JavaScript
can use your site.
Apply the Call JavaScript behavior
The Call JavaScript behavior executes a custom function or line of JavaScript code when an event occurs. (You can
write the script yourself, or you can use code provided by various freely available JavaScript libraries on the web.)
1 Select an object and choose Call JavaScript from the Add Behavior menu of the Behaviors panel.
2 Type the exact JavaScript to be executed, or type the name of a function.
For example, to create a Back button, you might type if (history.length > 0){history.back()}. If you have
encapsulated your code in a function, type only the function name (for example,
hGoBack()).
3 Click OK and verify that the default event is correct.
Apply the Change Property behavior
Use the Change Property behavior to change the value of one of an object’s properties (for example, the background
color of a div or the action of a form).
Note: Use this behavior only if you are very familiar with HTML and JavaScript.
1 Select an object and choose Change Property from the Add Behavior menu of the Behaviors panel.
2 From the Type Of Element menu, select an element type to display all the identified elements of that type.
3 Select an element from the Element ID menu.
4 Select a property from the Property menu, or enter the name of the property in the box.