Adobe 38040334 - Dreamweaver CS3 User Manual page 243

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

Advertisement

Example
The following example of the
passes user-specified parameters (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
This function inserts one or more functions—surrounded by the following tags, if they don't yet exist—into the head
section of the user's document:
<SCRIPT LANGUAGE="JavaScript"></SCRIPT>
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 user's document. This value must be exactly the same every time (it cannot depend
on user input). The functions are inserted only once, regardless of how many times the action is applied to elements
in the document.
Note: Quotation marks (
""
errors that the JavaScript interpreter reports.
Example
The following instance of the
function behaviorFunction(){
return ""+
_
"function MM
popupMsg(theMsg) { //v1.0\n"+
"alert(theMsg);\n"+
"}";
}
function returns a call to the
applyBehavior()
)within the returned string must be preceded by a backslash (\) escape character to avoid
behaviorFunction()
MM_openBrWindow()
function returns the
MM_popupMsg()
DREAMWEAVER CS3
Extending Dreamweaver
function and
function:
237

Advertisement

Table of Contents
loading

This manual is also suitable for:

Dreamweaver cs3

Table of Contents