You handle general editing functions in the Document window. These functions insert text, HTML, and objects; apply, change, and remove font and character markup; modify tags and attributes; and more.
dom.applyCharacterMarkup()
Availability
Dreamweaver 3.
Description
Applies the specified type of character markup to the selection. If the selection is an insertion point, it applies the specified character markup to any subsequently typed text.
Arguments
tagName
The tagName argument is the tag name that is associated with the character markup. It must be one of the following strings: "b", "cite", "code", "dfn", "em", "i", "kbd", "samp", "s", "strong", "tt", "u", or "var".
Returns
Nothing.
dom.applyFontMarkup()
Availability
Dreamweaver 3.
Description
Applies the FONT tag and the specified attribute and value to the current selection.
Arguments
attribute, value
The attribute argument must be "face", "size", or "color".
The value argument is the value to be assigned to the attribute; for example, "Arial, Helvetica, sans-serif", "5", or "#FF0000".
Returns
Nothing.
dom.deleteSelection()
Availability
Dreamweaver 3.
Description
Deletes the selection in the document.
Arguments
None.
Returns
Nothing.
dom.editAttribute()
Availability
Dreamweaver 3.
Description
Displays the appropriate interface for editing the specified Document attribute. In most cases, this interface is a dialog box. This function is valid only for the active document.
Arguments
attribute
The attribute is a string that specifies the tag attribute that you want to edit.
Returns
Nothing.
dom.exitBlock()
Availability
Dreamweaver 3.
Description
Exits the current paragraph or heading block, leaving the insertion point outside all block elements.
Arguments
None.
Returns
Nothing.
dom.getCharSet()
Availability
Dreamweaver 4.
Description
Returns the charset attribute in the meta tag of the document.
Arguments
None.
Returns
The encoding identity of the document. For example, for a Latin1 document, the function returns iso-8859-1.
dom.getFontMarkup()
Availability
Dreamweaver 3.
Description
Gets the value of the specified attribute of the FONT tag for the current selection.
Arguments
attribute
The attribute argument must be "face", "size", or "color".
Returns
A string that contains the value of the specified attribute or an empty string if the attribute is not set.
dom.getLineFromOffset()
Availability
Dreamweaver MX.
Description
Finds the line number of a specific character offset in the text (the HTML or JavaScript code) of the file.
Arguments
offset
The offset argument is an integer that represents the character location from the beginning of the file.
Returns
An integer that represents the line number in the document.
dom.getLinkHref()
Availability
Dreamweaver 3.
Description
Gets the link that surrounds the current selection. This function is equivalent to looping through the parents and grandparents of the current node until a link is found and then calling the getAttribute('HREF') on the link.
Arguments
None.
Returns
A string that contains the name of the linked file, which is expressed as a file:// URL.
dom.getLinkTarget()
Availability
Dreamweaver 3.
Description
Gets the target of the link that surrounds the current selection. This function is equivalent to looping through the parents and grandparents of the current node until a link is found and then calling the getAttribute('TARGET') function on the link.
Arguments
None.
Returns
A string that contains the value of the TARGET attribute for the link or an empty string if no target is specified.
dom.getListTag()
Availability
Dreamweaver 3.
Description
Gets the style of the selected list.
Arguments
None.
Returns
A string that contains the tag that is associated with the list ("ul", "ol", or "dl") or an empty string if no tag is associated with the list. This value always returns in lowercase letters.
dom.getTextAlignment()
Availability
Dreamweaver 3.
Description
Gets the alignment of the block that contains the selection.
Arguments
None.
Returns
A string that contains the value of the ALIGN attribute for the tag that is associated with the block or an empty string if the ALIGN attribute is not set for the tag. This value always returns in lowercase letters.
dom.getTextFormat()
Availability
Dreamweaver 3.
Description
Gets the block format of the selected text.
Arguments
None.
Returns
A string that contains the block tag that is associated with the text (for example, "p", "h1", "pre", and so on) or an empty string if no block tag is associated with the selection. This value always returns in lowercase letters.
dom.hasCharacterMarkup()
Availability
Dreamweaver 3.
Description
Checks whether the selection already has the specified character markup.
Arguments
markupTagName
The markupTagName argument is the name of the tag that you’re checking. It must be one of the following strings: "b", "cite", "code", "dfn", "em", "i", "kbd", "samp", "s", "strong", "tt", "u", or "var".
Returns
A Boolean value that indicates whether the entire selection has the specified character markup. The function returns a value of false if only part of the selection has the specified markup.
dom.indent()
Availability
Dreamweaver 3.
Description
Indents the selection using BLOCKQUOTE tags. If the selection is a list item, this function indents the selection by converting the selected item into a nested list. This nested list is of the same type as the outer list and contains one item, the original selection.
Arguments
None.
Returns
Nothing.
dom.insertHTML()
Availability
Dreamweaver 3.
Description
Inserts HTML content into the document at the current insertion point.
Arguments
contentToInsert, {bReplaceCurrentSelection}
The contentToInsert argument is the content you want to insert.
The bReplaceCurrentSelection argument, which is optional, is a Boolean value that indicates whether the content should replace the current selection. If the bReplaceCurrentSelection argument is a value of true, the content replaces the current selection. If the value is false, the content is inserted after the current selection.
Returns
Nothing.
Example
The following code inserts the HTML string <b>130</b> into the current document:
var theDOM = dw.getDocumentDOM(); theDOM.insertHTML('<b>130</b>');
The result appears in the Document window.
dom.insertObject()
Availability
Dreamweaver 3.
Description
Inserts the specified object, prompting the user for parameters if necessary.
Arguments
objectName
The objectName argument is the name of an object in the Configuration/Objects folder.
Returns
Nothing.
Example
A call to the dom.insertObject('Button') function inserts a form button into the active document after the current selection. If nothing is selected, this function inserts the button at the current insertion point.
Although object files can be stored in separate folders, it’s important that these files have unique names. If a file called Button.htm exists in the Forms folder and also in the MyObjects folder, Dreamweaver cannot distinguish between them.
dom.insertText()
Availability
Dreamweaver 3.
Description
Inserts text content into the document at the current insertion point.
Arguments
contentToInsert, {bReplaceCurrentSelection}
The contentToInsert argument is the content that you want to insert.
The bReplaceCurrentSelection argument, which is optional, is a Boolean value that indicates whether the content should replace the current selection. If the bReplaceCurrentSelection argument is a value of true, the content replaces the current selection. If the value is false, the content is inserted after the current selection.
Returns
Nothing.
Example
The following code inserts the text: <b>130</b> into the current document:
var theDOM = dreamweaver.getDocumentDOM(); theDOM.insertText('<b>130</b>');
The results appear in the Document window.
dom.newBlock()
Availability
Dreamweaver 3.
Description
Creates a new block with the same tag and attributes as the block that contains the current selection or creates a new paragraph if the pointer is outside all blocks.
Arguments
None.
Returns
Nothing.
Example
If the current selection is inside a center-aligned paragraph, a call to the dom.newBlock() function inserts <p align="center"> after the current paragraph.
dom.notifyFlashObjectChanged()
Availability
Dreamweaver 4.
Description
Tells Dreamweaver that the current Flash object file has changed. Dreamweaver updates the Preview display, resizing it as necessary, preserving the width-height ratio from the original size.
Arguments
None.
Returns
Nothing.
dom.outdent()
Availability
Dreamweaver 3.
Description
Outdents the selection.
Arguments
None.
Returns
Nothing.
dom.removeCharacterMarkup()
Availability
Dreamweaver 3.
Description
Removes the specified type of character markup from the selection.
Arguments
tagName
The tagName argument is the tag name that is associated with the character markup. It must be one of the following strings: "b", "cite", "code", "dfn", "em", "i", "kbd", "samp", "s", "strong", "tt", "u", or "var".
Returns
Nothing.
dom.removeFontMarkup()
Availability
Dreamweaver 3.
Description
Removes the specified attribute and its value from a FONT tag. If removing the attribute leaves only the FONT tag, the FONT tag is also removed.
Arguments
attribute
The attribute argument must be "face", "size", or "color".
Returns
Nothing.
dom.resizeSelection()
Availability
Dreamweaver 3.
Description
Resizes the selected object to the specified dimensions.
Arguments
newWidth, newHeight
The newWidth argument specifies the new width to which the function will set the selected object.
The newHeight argument specifies the new height to which the function will set the selected object.
Returns
Nothing.
dom.setAttributeWithErrorChecking()
Availability
Dreamweaver 3.
Description
Sets the specified attribute to the specified value for the current selection, prompting the user if the value is the wrong type or if it is out of range. This function is valid only for the active document.
Arguments
attribute, value
The attribute argument specifies the attribute to set for the current selection.
The value argument specifies the value to set for the attribute.
Returns
Nothing.
dom.setLinkHref()
Availability
Dreamweaver 3.
Description
Makes the selection a hypertext link or changes the URL value of the HREF tag that encloses the current selection.
Arguments
linkHREF
The linkHREF argument is the URL (document-relative path, root-relative path, or absolute URL) comprising the link. If this argument is omitted, the Select HTML File dialog box appears.
Returns
Nothing.
Enabler
See dom.canSetLinkHref().
dom.setLinkTarget()
Availability
Dreamweaver 3.
Description
Sets the target of the link that surrounds the current selection. This function is equivalent to looping through the parents and grandparents of the current node until a link is found and then calling the setAttribute('TARGET') function on the link.
Arguments
{linkTarget}
The linkTarget argument, which is optional, is a string that represents a frame name, window name, or one of the reserved targets ("_self", "_parent", "_top", or "_blank"). If the argument is omitted, the Set Target dialog box appears.
Returns
Nothing.
dom.setListBoxKind()
Availability
Dreamweaver 3.
Description
Changes the kind of the selected SELECT menu.
Arguments
kind
The kind argument must be either "menu" or "list box".
Returns
Nothing.
dom.showListPropertiesDialog()
Availability
Dreamweaver 3.
Description
Opens the List Properties dialog box.
Arguments
None.
Returns
Nothing.
Enabler
dom.setListTag()
Availability
Dreamweaver 3.
Description
Sets the style of the selected list.
Arguments
listTag
The listTag argument is the tag that is associated with the list. It must be "ol", "ul", "dl", or an empty string.
Returns
Nothing.
dom.setTextAlignment()
Availability
Dreamweaver 3.
Description
Sets the ALIGN attribute of the block that contains the selection to the specified value.
Arguments
alignValue
The alignValue argument must be "left", "center", or "right".
Returns
Nothing.
dom.setTextFieldKind()
Availability
Dreamweaver 3 (deprecated since Dreamweaver CS5.5)
Description
Sets the format of the selected text field.
Arguments
fieldType
The fieldType argument must be "input", "textarea", or "password".
Returns
Nothing.
dom.setTextFormat()
Availability
Dreamweaver 4.
Description
Sets the block format of the selected text.
Arguments
blockFormat
The blockFormat argument is a string that specifies one of the following formats: "" (for no format), "p", "h1", "h2", "h3", "h4", "h5", "h6", or "pre".
Returns
Nothing.
dom.showFontColorDialog()
Availability
Dreamweaver 3.
Description
Opens the Color Picker dialog box.
Arguments
None.
Returns
Nothing.
dreamweaver.deleteSelection()
Availability
Dreamweaver 3.
Description
Deletes the selection in the active document or the Site panel; on the Macintosh, it deletes the text box that has focus in a dialog box or floating panel.
Arguments
None.
Returns
Nothing.
Enabler
dreamweaver.editFontList()
Availability
Dreamweaver 3.
Description
Opens the Edit Font List dialog box.
Arguments
None.
Returns
Nothing.
dreamweaver.getFontList()
Availability
Dreamweaver 3.
Description
Gets a list of all the font groups that appear in the text Property inspector and in the Style Definition dialog box.
Arguments
None.
Returns
An array of strings that represent each item in the font list.
Example
For the default installation of Dreamweaver, a call to the dreamweaver.getFontList() function returns an array that contains the following items:
"Arial, Helvetica, sans-serif"
"Times New Roman, Times, serif"
"Courier New, Courier, mono"
"Georgia, Times New Roman, Times, serif"
"Verdana, Arial, Helvetica, sans-serif"
dreamweaver.getFontStyles()
Availability
Dreamweaver 4.
Description
Returns the styles that a specified TrueType font supports.
Arguments
fontName
The fontName argument is a string that contains the name of the font.
Returns
An array of three Boolean values that indicates what the font supports. The first value indicates whether the font supports bold, the second indicates whether the font supports italic, and the third indicates whether the font supports both bold and italic.
dreamweaver.getKeyState()
Availability
Dreamweaver 3.
Description
Determines whether the specified modifier key is depressed.
Arguments
key
The key argument must be one of the following values: "Cmd", "Ctrl", "Alt", or "Shift". In Windows, "Cmd" and "Ctrl" refer to the Control key; on the Macintosh, "Alt" refers to the Option key.
Returns
A Boolean value that indicates whether the key is pressed.
Example
The following code checks that both the Shift and Control keys (Windows) or Shift and Command keys (Macintosh) are pressed before performing an operation:
if (dw.getKeyState("Shift") && dw.getKeyState("Cmd")){ // execute code }
dreamweaver.getNaturalSize()
Availability
Dreamweaver 4.
Description
Returns the width and height of a graphical object.
Arguments
url
The url argument points to a graphical object for which the dimensions are wanted. Dreamweaver must support this object (GIF, JPEG, PNG, Flash, and Shockwave). The URL that is provided as the argument to the getNaturalSize() function must be an absolute URL that points to a local file; it cannot be a relative URL.
Returns
An array of two integers where the first integer defines the width of the object, and the second defines the height.
dreamweaver.getSystemFontList()
Availability
Dreamweaver 4.
Description
Returns a list of fonts for the system. This function can get either all fonts or only TrueType fonts.
Arguments
fontTypes
The fontTypes argument is a string that contains either the value all, or the value TrueType.
Returns
An array of strings that contain the entire font names; returns a value of null if no fonts are found.
dreamweaver.getSystemFontName()
Availability
Dreamweaver CS5.
Description
Returns the system font name.
Arguments
Nothing.
Returns
A string containing the system font name.