A Simple Behavior Example - Adobe 38040334 - Dreamweaver CS3 User Manual

Extending dreamweaver
Hide thumbs Also See for 38040334 - Dreamweaver CS3:
Table of Contents

Advertisement

To get around this limitation, set the
string that the
behaviorFunction()
document.MM_returnValue
variable, see the Validate Form.js file in the Configuration/Behaviors/Actions folder within the
MM_returnValue
Dreamweaver application folder.

A simple behavior example

To understand how behaviors work and how you can create one, it's helpful to look at an example. The
Configuration/Behaviors/Actions folder inside the Dreamweaver application folder contains examples; however,
many are very complex. This example is simpler so that you can learn about creating behaviors. Start with the simple
Action file Call JavaScript.htm (along with its counterpart, Call JavaScript.js, which contains all the JavaScript
functions).
To create the behavior, you perform the following steps:
• "Creating the behavior extension" on page 232
• "Creating the HTML files to browse" on page 234
• "Testing the behavior" on page 236
Creating the behavior extension
The following code presents a relatively simple example. It checks the brand of the browser and goes to one page if
the brand is Netscape Navigator and another if the brand is Microsoft Internet Explorer. This code can easily be
expanded to check for other brands such as Opera and WebTV and modified to perform actions other than going
to URLs.
To create the behavior extension:
Create a new blank file.
1
Add the following to the file:
2
<!DOCTYPE HTML SYSTEM "-//Macromedia//DWExtension layout-engine 5.0//dialog">
<html>
<head>
<title>behavior "Check Browser Brand"</title>
<meta http-equiv="Content-Type" content="text/html">
<script language="JavaScript">
// The function that will be inserted into the
// HEAD of the user's document
function checkBrowserBrand(netscapeURL,explorerURL) {
if (navigator.appName == "Netscape") {
if (netscapeURL) location.href = netscapeURL;
}else if (navigator.appName == "Microsoft Internet Explorer") {
if (explorerURL) location.href = explorerURL;
}
}
//******************* API **********************
document.MM_returnValue
function returns. This setting causes Dreamweaver to insert
at the end of the list of actions in the event handler. For an example that uses the
variable to the desired return value within the
DREAMWEAVER CS3
232
Extending Dreamweaver
return

Advertisement

Table of Contents
loading

This manual is also suitable for:

Dreamweaver cs3

Table of Contents