
A dynamic menu example 201
The setMenuText() function looks like the following example code:
function setMenuText()
{
if (arguments.length != 1) return "";
var whatToDo = arguments[0];
if (whatToDo == "undo")
return dw.getUndoText();
else if (whatToDo == "redo")
return dw.getRedoText();
else return "";
}
Placing the command file in the Menu folder
To implement the menu Undo and Redo menu items, you must save the MyMenu.htm
command file in the Dreamweaver Configuration/Menus folder or a subfolder that you
create. The location of the file must agree with the location that you specified in the
menuitem tag. To make it accessible to Dreamweaver, either restart Dreamweaver or reload
extensions. For information on how to reload extensions, see “Reloading extensions”
on page 104.
To run the menu commands, select the menu item when it is enabled. Dreamweaver will
invoke the functions in the command file, as described in “How menu commands work”
on page 196.
A dynamic menu example
This example implements the Dreamweaver Preview in Browser submenu that displays a list
of available browsers. The example also opens the current file, or the selected files in the Site
panel, in the user-specified browser. Implementing this dynamic menu consists of the
following steps:
■ Creating the dynamic menu items
■ Writing the JavaScript code
Comentarios a estos manuales