Specifications

Behaviors 137
Returns
Dreamweaver expects a string that contains the function call to be inserted in the users
document, usually after accepting parameters from the user. If
applyBehavior() determines that
the user made an invalid entry, the function can return an error string instead of the function call.
If the string is empty (
return "";), Dreamweaver does not report an error; if the string is not
empty and not a function call, Dreamweaver displays a dialog box with the text:
Invalid input
supplied for this behavior: [the string returned from applyBehavior()]
. If the
return value is
null (return;), Dreamweaver indicates that an error occurred but gives no
specific information.
Note: Quotation marks within the returned string must be preceded by a backslash (\) to avoid errors that the
JavaScript interpreter reports.
Example
The following instance of applyBehavior() returns a call to the function MM_openBrWindow()
and passes parameters that are given by the user (the height and width of the window; whether
the window should have scroll bars, a toolbar, a location bar, and other features; and the URL
that should open in the window):
function applyBehavior() {
var i,theURL,theName,arrayIndex = 0;
var argArray = new Array(); //use array to produce correct ¬
number of commas w/o spaces
var checkBoxNames = new Array("toolbar","location",¬
"status","menubar","scrollbars","resizable");
for (i=0; i<checkBoxNames.length; i++) {
theCheckBox = eval("document.theForm." + checkBoxNames[i]);
if (theCheckBox.checked) argArray[arrayIndex++] = ¬
(checkBoxNames[i] + "=yes");
}
if (document.theForm.width.value)
argArray[arrayIndex++] = ("width=" + ¬
document.theForm.width.value);
if (document.theForm.height.value)
argArray[arrayIndex++] = ("height=" + ¬
document.theForm.height.value);
theURL = escape(document.theForm.URL.value);
theName = document.theForm.winName.value;
return "MM_openBrWindow('"+theURL+"',¬
'"+theName+"','"+argArray.join()+"')";
}
behaviorFunction()
Description
Inserts one or more functionssurrounded by <SCRIPT LANGUAGE="JavaScript"></SCRIPT>
tags, if none yet existinto the
HEAD of the users document.
Arguments
None.
Returns
Dreamweaver expects either a string that contains the JavaScript functions or a string that
contains the names of the functions to be inserted in the users document. This value must be
exactly the same every time (it cannot depend on input from the user). The functions are inserted
only once, regardless of how many times the action is applied to elements in the document.