MACROMEDIA DREAMWEAVER MX 2004-EXTENDING DREAMWEAVER Specifikace Strana 318

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 504
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 317
318 Behaviors
Example
This simple example of the identifyBehaviorArguments() function works for the Open
Browser Window behavior action, which returns a function that always has three arguments
(the URL to open, the name of the new window, and the list of window properties):
function identifyBehaviorArguments(fnCallStr) {
return "URL,other,other";
}
A more complex version of the identifyBehaviorArguments() function is necessary for
behavior functions that have a variable number of arguments (such as Show/Hide Layer). For
this example version of the
identifyBehaviorArguments() function, there is a minimum
number of arguments, and additional arguments always come in multiples of the minimum
number. In other words, a function with a minimum number of arguments of 4 may have 4,
8, or 12 arguments, but it cannot have 10 arguments:
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";
}
}
Zobrazit stránku 317
1 2 ... 313 314 315 316 317 318 319 320 321 322 323 ... 503 504

Komentáře k této Příručce

Žádné komentáře