[Back to Jeff W's Dreamweaver home]

Some useful things in the Behaviors palette

The Behaviors palette in DW is a set of extensible Javascripts identified by function descriptions.  Ideally, you should be able to select "open new window," type in some attributes, and voila - when your whatever is activated, a window opens.

It's not quite that simple, though.  Here's why:

1. Javascripts only operate in certain environments.  Scripts that can work on loading a page can't work on loading a graphic.  The short of it is that you sort of have to know what you're asking for - the more Javascript you know, the better the behaviors work for you - but the less you need them.

2. The scripts don't always work, or don't work the way you'd expect.  I haven't evaluated this methodically, but you saw one example in class the other night.  In short, they don't seem rock-solid.

3. Even when subtracted from the Behaviors palette, script elements can remain.  So if you select a rollover and pre-load the images, but later remove the rollover - the preload images script won't be deleted.  You have to watch your source code and clean up behind DW.

So what's the Behaviors palette good for?  Here are a few things that I use myself or see from time to time on pro sites.

1. Image rollovers.  These scripts apparently work well in DW 2+.  My only caveat is the "pre-load images" script additon, for the reason given in #3 and because there's a simpler non-JS way to do this - just add the rollover image tags to the end of your document, but set the height and width attributes to 1 x 1.

2. Onload functions.  If you want something to happen when a page loads - a window to pop up, or new page to be pulled, or a print dialog box to be displayed (need a Behaviors extension for this), select the <BODY> tag (have to do this in code view), and see what's available in the Behaviors palette.

3. Quick and dirty popup windows.  If you just need a window to pop up somehow, the "Open window" command is o.k.  It functions differently depending on which browser version you select, and may not function right (it may pop up the window and roll over the originating page to the same page as the window), but if you get the hang of it, I dunno, maybe it's easier than using the better script generator from WebReview.  For any pro site, though, I'd use the generator below - it lets you position popup windows in v4 browsers, and doesn't have the bugs mentioned in DW.

webreview.com/wr/pub/98/11/06/feature/popgenerator.html

4. Form validation. This is nice - be sure to give all your form elements names (the leftmost box on the properties inspector for each element), and choose the <FORM> tag before opening Behaviors - and you'll have options for verifying form fields prior to submission, including verifying for e-mail addresses.

5. Browser check - I reckon...I see DW Behaviors JS for browser checking on pro sites from time to time, but I've never dug into just what folks are doing the checking for.