Writing the JavaScript code
When the user interacts with the text box, it causes Dreamweaver to invoke the EditTitle.htm
command file in the Toolbars/MM folder. This file contains three JavaScript functions that
operate on the Title text box. These functions are
receiveArguments(),
canAcceptCommand(): enable the toolbar item
The
canAcceptCommand()
current DOM and if the document is parsed as HTML. The function returns the result of those
tests. If the conditions are
function returns the value
function canAcceptCommand()
{
return (dw.getDocumentDOM() != null && dw.getDocumentDOM().getParseMode() ==
'html');
}
receiveArguments(): set the title
Dreamweaver invokes the
when the user enters a value in the Document Title text box and presses the Enter key or moves
the focus away from the control:
function receiveArguments(newTitle)
{
var dom = dw.getDocumentDOM();
if (dom)
dom.setTitle(newTitle);
}
Dreamweaver passes
receiveArguments()
current DOM exists. If it does, the
by passing
newTitle
getCurrentValue(): get the title
Whenever an update cycle occurs, as determined by the default update frequency of the
event handler, Dreamweaver calls the
display for the control. The default update frequency of the
update frequency because the Title text edit control has no update attribute.
For the Document Title text box, the following
API function
dom.getTitle()
function getCurrentValue()
{
var title = "";
var dom = dw.getDocumentDOM();
if (dom)
title = dom.getTitle();
return title;
}
and
getCurrentValue().
function consists of one line of code that checks to see if there is a
, Dreamweaver enables text box item on the toolbar. If the
true
Dreamweaver disables the item.
false,
receiveArguments()
, which is the value that the user enters, to the
newTitle
function. The
receiveArguments()
receiveArguments()
to the
dom.setTitle()
getCurrentValue()
to obtain and return the current title:
canAcceptCommand(),
function, shown in the following example,
function first checks to see if a
function sets the new document title
function.
function to determine what value to
onEdit
getCurrentValue()
A simple toolbar command file
onEdit
handler determines the
function calls the JavaScript
195
Need help?
Do you have a question about the DREAMWEAVER MX 2004-EXTENDING DREAMWEAVER and is the answer not in the manual?
Questions and answers