Returns
Dreamweaver expects a string that contains an error message or an empty string. If it returns an
empty string, the Object dialog box closes when the user clicks OK. If it is not empty,
Dreamweaver displays the error message and the dialog box remains.
Enabler
canInsertObject()
Example
The following example uses the
before inserting code:
function insertObject() {
var theForm = document.forms[0];
var nameVal = theForm.firstField.value;
var passwordVal = theForm.secondField.value;
var errMsg = "",
var isValid = true;
// ensure that field values are complete and valid
if (nameVal == "" || passwordVal == "") {
errMsg = "Complete all values or click Cancel."
} else if (nameVal.length < 4 || passwordVal.length < 6) {
errMsg = "Your name must be at least four characters, and your password at
least six";
}
if (!errMsg) {
// do some document manipulation here. Exercise left to the reader
}
return errMsg;
}
objectTag()
Description
The
objectTag()
document, the
objectTag()
on page
123.
This function inserts a string of code into the user's document. In Dreamweaver MX, returning
an empty string, or a
do nothing.
Note: The assumption is that edits have been made manually before the
nothing in this case is not equivalent to clicking Cancel.
In Dreamweaver 4, if the focus is in Code view and the selection is a range (meaning that it is not
an insertion point), the range is replaced by the string that the
This is the value
nothing. The reason for returning an empty string, or a
function is because edits to the document have already been made manually. Otherwise, double
quotes ("") often deletes the edit by replacing the selection.
124
Chapter 6: Insert Bar Objects
insertObject()
and
insertObject()
function is used. For more information, see
value (also known as "
null
, even if the
true
objectTag()
function because it needs to validate input
functions are mutually exclusive: If both are defined in a
;"), is a signal to Dreamweaver to
return
objectTag()
function returns an empty string or returns
value from the
null
"insertObject()"
statement, so doing
return
function returns.
objectTag()
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