Quantunet.com

My Account

Joins Us
Dreamweaver 8 QuickSkills

Working With Behaviors

 

What are behaviors?

A behavior is an action that is triggered by and event. When a behavior is added to a web page dreamweaver adds a small peice of javascript code that controls how and when an object acts when the user interacts with it. User interaction can be in the form of a mouse click, hover or when an object has finshed loading. Javascript can detech user interacts in the form of events, depending on which event is deteched a specific function is be called that controls how the object reacts.

event + action = behavior

For example:

[Creating a simple behavior]
[Removing a behavior]

There a number of different events that can be used in dreamweaver here are some of the more commonly used ones.

Mouse events

  • onClick
  • onMouseOver
  • onMouse Down
  • onMouseUp
  • onMouseOut

Object Events

  • onLoad
  • onUnload
  • onSelect
  • onChange
  • onSubmit

Web Page Events

  • onBlur
  • onFocus


A single event can have a single action but behaviors can also be used to assiciate a series of actions with an event and set the order in which the actions occur creating complex behaviors. Which can be a great way to build usability, inteactivity and accesibility into your website.



Common Applications Of Behaviors In Web Pages

Playing a sound on mouse over or mouse click

In Dreamweaver sounds can also be controled by behaviors in fact dreamweaver has a built in way to create a simple "play sound when" behavior. However when using this feature the behavior does not give a method by which the sound can be turned off before it has finished playing. So if you use a piece of music when the behavior is triggered by a rollover, click or onload event the song will play all the way to the end and then stop. When using sound in this way it is recommended to use short sound effects such as clicks as they respond to the user interaction swfly and end quickly otherwise the user is stuck waiting for the sound to load then listening to the song with no way of stopping it other than refreshing the page This should be avioded as it generates a poor user experience.

Sound effects can be used with image based buttons or pictures but when using flash buttons it would be more consistent to use an embedded mp3 file in the same swf file and use flash's native events to control it.
To learn how to play a sound using behaviors in Dreamwever see: [Playing sound when mouse is clicked]
(depreciated)

Showing & Hiding Elements Using Behaviors

To show an hide an image or object you need to create two behaviors. One controls when to make the object appear and the other controls when to make the object dissappear.
For example:

See [Making layers visible on mouse over]

Sawp Images Using Behaviors

[Creating An Image rollover]

Pop Up Messages Using Behaviors

[Creating a Popup Message]

Popup Menus Using Behaviors
(depreciated)
[Creating a popup menu]

Validating Form Entries using Behaviors

[Validating form entries]
[Validating email addresses]
[Validating phone numbers]
[Making fields required]

Limitations and Problems Associated with Using Evets and Behaviors

  • Requires javascript to run
  • Not all events are supported by all browsers
  • Can slow a browsing experice
  • Other methids give more sophistcated control over behavior (flash)

Behaviors are client side scripts that run in web browser. The scripts senses user events and then controls an object actions. This is all done using the web browser andthe users CPU . This means that websites running client side scripts make the user run the cpu intensitve application leaving the server free to simply deliver scripts to visitors.


Note: The depreciation of this technique for desiging and building web pages.

© 2007 Quantunet LLC All Rights Reserved | Intellectual Property | Terms of Use | Privacy
Home | About Quantunet | FAQ's | Contact Us