Inspectbehavior() – Adobe Extending Dreamweaver CS4 User Manual
Page 250

244
EXTENDING DREAMWEAVER CS4
Behaviors
function identifyBehaviorArguments(fnCallStr) {
var listOfArgTypes;
var itemArray = dreamweaver.getTokens(fnCallStr, '(),');
// The array of items returned by getTokens() includes the
// function name, so the number of *arguments* in the array
// is the length of the array minus one. Divide by 4 to get the
// number of groups of arguments.
var numArgGroups = ((itemArray.length - 1)/4);
// For each group of arguments
for (i=0; i < numArgGroups; i++){
// Add a comma and "NS4.0ref,IE4.0ref,other,dep" (because this
// hypothetical behavior function has a minimum of four
// arguments the Netscape object reference, the IE object
// reference, a dependent URL, and perhaps a property value
// such as "show" or "hide") to the existing list of argument
// types, or if no list yet exists, add only
// "NS4.0ref,IE4.0ref,other,dep"
var listOfArgTypes += ((listOfArgTypes)?",":"") + ¬
"NS4.0ref,IE4.0ref,other,dep";
}
}
inspectBehavior()
Description
This function inspects the function call for a previously applied behavior in the user’s document and sets the values of
the options in the Parameters dialog box accordingly. If the
inspectBehavior()
function is not defined, the default
option values appear.
Note: The i
nspectBehavior()
function must rely solely on information that the
applyBehaviorString
argument
passes to it. Do not attempt to obtain other information about the user’s document (for example, using
dreamweaver.getDocumentDOM()
) within this function.
Arguments
applyBehaviorString
This argument is the string that the
applyBehavior()
function returns.
Note: If the HTML element contains code that is similar to '
onClick="someBehavior(); return
document.MM_returnValue;"'
, and you add a new behavior from the behavior menu, Dreamweaver calls
inspectBehavior()
as soon as the new behavior UI pops up, and passes an empty string as the parameter.
Consequently, be sure to check the
applyBehaviorString
parameter, as shown in the following example:
function inspectBehavior(enteredStr){
if(enteredStr){
//do your work here
}
}
Returns
Dreamweaver expects nothing.