Creating the dynamic menu items
The following menu tags in the menus.xml file define the Preview in Browser submenu of the
File menu:
<menu name="_Preview in Browser" id="DWMenu_File_PIB">
<menuitem dynamic name="No Browsers Selected"
file="Menus/MM/PIB_Dynamic.htm" arguments="'No Browsers'"
id="DWMenu_File_PIB_Default" />
<separator />
<menuitem name="_Edit Browser List..." enabled="true"
command="dw.editBrowserList()" id="DWMenu_File_PIB_EditBrowserList" />
</menu>
The first
tag defines the default menu item No Browsers Selected, which appears
menuitem
on the submenu if you have not specified any browsers for the Preview in Browser item in
Preferences. If you specified the Microsoft Internet Explorer browser, however, the submenu
would look like the following figure:
The
attribute for the first menu item specifies the command file PIB_Dynamic.htm.
name
This file contains the following line:
<SCRIPT LANGUAGE="javascript" SRC="PIB_Dynamic.js"></SCRIPT>
The
tag includes the JavaScript code in the PIB_Dynamic.js file, which supplies the
script
JavaScript code that interacts with the Preview in Browser submenu. This code could be saved
directly in the PIB_Dynamic.htm file, but storing it in a separate file allows multiple
commands to include the same code.
Writing the JavaScript code
Because the first
menuitem
getDynamicContent()
example:
function getDynamicContent(itemID)
{
var browsers = null;
var PIB = null;
var i;
var j=0;
browsers = new Array();
PIB = dw.getBrowserList();
202
Menus and Menu Commands
tag contains the
dynamic
function in the PIB_Dynamic.js file, which is shown in the following
attribute, Dreamweaver calls the
Need help?
Do you have a question about the DREAMWEAVER 8-EXTENDING DREAMWEAVER and is the answer not in the manual?
Questions and answers