Specifications

Menu Commands 75
A simple dynamic menu
The following menu command generates the Preview in Browser submenu, and it launches the
current file (or the selected files in the Site panel) in the browser that the user chooses from the
submenu.
<HTML>
<HEAD>
<!-- Copyright 1999 Macromedia, Inc. All rights reserved. -->
<TITLE>Preview Browsers</TITLE>
<SCRIPT LANGUAGE="javascript">
<!--
// getDynamicContent returns the contents of a dynamically
// generated menu.
// returns an array of strings to be placed in the menu, with a unique
// identifier for each item separated from the menu string by a
// semicolon.
//
// return null from this routine to indicate that you are not
// adding any
// items to the menu
function getDynamicContent(itemID)
{
var browsers = null;
var PIB = null;
var i;
var j=0;
var bUpdate = dw.getMenuNeedsUpdating(itemID);
if (bUpdate)
{
browsers = new Array();
PIB = dw.getBrowserList();
// each browser pair has the name of the browser and the path
// that leads to the application on disk. We only put the
// names in the menus.
for (i=0; i<PIB.length; i=i+2)
{
browsers[j] = new String(PIB[i]);
if (dw.getPrimaryBrowser() == PIB[i+1])
browsers[j] += "\tF12";
if (navigator.platform == "MacPPC")
{
if (dw.getSecondaryBrowser() == PIB[i+1])
browsers[j] += "\t ?F12";
}
else
{
if (dw.getSecondaryBrowser() == PIB[i+1])
browsers[j] += "\t Ctrl+F12";
}
browsers[j] += ";id=’"+PIB[i]+"’";
j = j+1;
}
dw.notifyMenuUpdated(itemID, "dw.getBrowserList()");
}
return browsers;
}
function canAcceptCommand()