Writing the JavaScript code

Because the first menuitem tag contains the dynamic attribute, Adobe Dreamweaver calls the getDynamicContent() function in the PIB_Dynamic.js file, which is shown in the following example:

function getDynamicContent(itemID){ var browsers = null; var PIB = null; var i; var j=0; browsers = new Array(); PIB = dw.getBrowserList();  for (i=0; i<PIB.length; i=i+2) { browsers[j] = new String(PIB[i]); if (dw.getPrimaryBrowser() == PIB[i+1]) browsers[j] += "\tF12"; else if (dw.getSecondaryBrowser() == PIB[i+1]) browsers[j] += "\tCmd+F12"; browsers[j] += ";id='"+escQuotes(PIB[i])+"'"; if (itemID == "DWPopup_PIB_Default") browsers[j] = MENU_strPreviewIn + browsers[j];  j = j+1; } return browsers;}

The getDynamicContent() function calls the dw.getBrowserList() function to obtain an array of the browser names that have been specified in the Preview in Browser section of Adobe Dreamweaver Preferences. This array contains the name of each browser and the path to the executable file. Next, for each item in the array (i=0; i<PIB.length; i=i+2), the getDynamicContents() function moves the name of the browser (PIB[i]) into a second array called browsers (browsers[j] = new String(PIB[i]);). If the browser has been designated as the primary or secondary browser, the function appends the names of the keyboard shortcut keys that invoke them. Next it appends the string ";id=" followed by the name of the browser in single quotes (for example, ;id='iexplore'). If the itemID argument is "DWPopup_PIB_Default", the function prefixes the array item with the string Preview in. After it constructs an entry for each browser listed in Preferences, the getDynamicContent() function returns the array browsers to Adobe Dreamweaver. If no browsers have been selected in Preferences, the function returns the value null, and Adobe Dreamweaver displays No Browsers Selected in the menu.