Macromedia dreamweaver 8-using dreamweaver Benutzerhandbuch

Seite von 1030
500
Chapter 18:  Using JavaScript Behaviors
Although the Dreamweaver actions were written to maximize cross-browser compatibility, 
some actions do not work in older browsers. Also, 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 still use your site.
Call JavaScript
The Call JavaScript action lets you use the Behaviors panel to specify that a custom function 
or line of JavaScript code should be executed when an event occurs. (You can write the 
JavaScript yourself, or you can use code provided by various freely available JavaScript libraries 
on the web.)
To use the Call JavaScript action:
1.
Select an object and open the Behaviors panel.
2.
Click the Plus (+) button and select Call JavaScript from the Actions pop-up menu.
3.
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, hogback()).
4.
Click OK.
5.
Check that the default event is the one you want.
If it isn’t, select another event from the pop-up menu. If the events you want are not listed, 
change the target browser in the Show Events For pop-up menu.
Change Property
Use the Change Property action to change the value of one of an object’s properties (for 
example, the background color of a layer or the action of a form). The properties you can 
change are determined by the browser; many more properties can be changed by this behavior 
in Internet Explorer 4.0 than in Internet Explorer 3.0 or Netscape Navigator 3.0 or 4.0. For 
example, you can set the background color of a layer dynamically.
NOT
E
Use this action only if you are very familiar with HTML and JavaScript.