User Guide
168 Chapter 8: Menus and Menu Commands
For each item in the selected list, the function tests for the presence of the character string
"
://". If it is not found, the code performs a series of tests on the list item. If the item is not in
the form of a
file:/// URL (if (selFile.indexOf(urlPrefix) == -1)), it sets the return
value to
false. If the remainder of the string following the file:/// prefix does not contain a
slash (/) (
if (strTemp.indexOf("/") == -1)), it sets the return value to false. If the file does
not exist (
else if (!DWfile.exists(selFile))), it sets the return value to false. Last, it
checks to see if the specified file is a folder (
else if
(DWfile.getAttributes(selFile).indexOf("D") != -1)
). If selfile is a folder, the
function returns the value
false. Otherwise, if the target is a file, the function sets
bHavePreviewTarget to the value true.
If a document, Text view, or the Code inspector have focus (
else if (dw.getFocus() ==
'document' || dw.getFocus() == 'textView' || dw.getFocus("true") == 'html' )
),
the function gets the DOM and checks to see if the document is an HTML or an XML
document. If so, the function sets
bHavePreviewTarget to true. Finally, the function returns
the value stored in
bHavePreviewTarget.
receiveArguments()
Dreamweaver calls the receiveArguments() function to let the command process
any arguments that pass from the menu item. For the Preview in Browsers menu,
the receiveArguments() function invokes the browser that the user selects.
The receiveArguments() function looks like the following example:
function receiveArguments()
{
var whichBrowser = arguments[0];
var theBrowser = null;
var i=0;
var browserList = null;
var result = false;
if (havePreviewTarget())
{
// Code to check if we were called from a shortcut key
if (whichBrowser == 'primary' || whichBrowser == 'secondary')
{
// get the path of the selected browser
if (whichBrowser == 'primary')
{
theBrowser = dw.getPrimaryBrowser();
}
else if (whichBrowser == 'secondary')
{
theBrowser = dw.getSecondaryBrowser();
}
// match up the path with the name of the corresponding browser
// that appears in the menu
browserList = dw.getBrowserList();
while (i < browserList.length)
{
if (browserList[i+1] == theBrowser)
theBrowser = browserList[i];
i+=2;
}
}
else
theBrowser = whichBrowser;