The Dreamweaver DOM contains a subset of objects, properties, and methods from the World Wide Web Consortium (W3C) DOM Level 1 specification, which are combined with some properties of the Microsoft Internet Explorer 4.0 DOM.

Objects, properties, and methods of the Dreamweaver DOM

The following table lists the objects, properties, methods, and events that the Dreamweaver DOM supports. Some properties are read-only when they are accessed as properties of a specific object. A bullet (•) indicates properties that are read-only when they are used in the listed context.

Object

Properties

Methods

Events

window

navigator

document

innerWidth •

innerHeight

screenX

screenY

alert()

confirm()

escape()

unescape()

close()

setTimeout()

clearTimeout()

setInterval()

clearInterval()

resizeTo()

onResize

navigator

platform

None

None

document

forms • (an array of form objects)

images • (an array of image objects)

layers • (an array of LAYER, ILAYER, and absolutely positioned elements)

child objects by name

nodeType

parentNode

childNodes

previousSibling

nextSibling

documentElement

body

URL

parentWindow

getElementsByTagName()

getElementsByAttributeName()

getElementById()

hasChildNodes()

onLoad

all tags/ elements

nodeType

parentNode •

childNodes

tagName

previousSibling

nextSibling

attributes by name

innerHTML

outerHTML

getAttribute()

setAttribute()

removeAttribute()

getElementsByTagName()

getElementsByAttributeName()

hasChildNodes()

form

In addition to the properties that are available for all tags:

tags:elements • (an array of button, checkbox, password, radio, reset, select, submit, text, file, hidden, image, and textarea objects)

mmcolorbutton

child objects by name •

Only those methods available to all tags

None

layer

In addition to the properties that are available for all tags:

visibility

left

top

width

height

zIndex

Only those methods that are available to all tags

None

image

In addition to the properties that are available for all tags:

src

Only those methods that are available to all tags

onMouseOver onMouseOut onMouseDown onMouseUp

button reset submit

In addition to the properties that are available for all tags:

form •

In addition to the methods that are available for all tags:

blur()

focus()

onClick

checkbox radio

In addition to the properties that are available for all tags: checked

form

In addition to the methods that are available for all tags:

blur()

focus()

onClick

password text file hidden image (field) textarea

In addition to the properties that are available for all tags:

form

value

In addition to the methods that are available for all tags:

blur()

focus()

select()

onBlur onFocus

select

In addition to the properties that are available for all tags:

form

options •(an array of option objects)

selectedIndex

In addition to the methods that are available for all tags:

blur() (Windows only)

focus() (Windows only)

onBlur (Windows only) onChange onFocus (Windows only)

option

In addition to the properties that are available for all tags:

text

Only those methods that are available to all tags

None

mmcolorbutton

In addition to the properties that are available for all tags:

name

value

None

onChange

array

boolean

date

function

number

object

string

regexp

Matches Netscape Navigator 4.0

Matches Netscape Navigator 4.0

None

text

nodeType

parentNode

childNodes

previousSibling

nextSibling

data

hasChildNodes()

None

comment

nodeType

parentNode

childNodes

previousSibling

nextSibling

data

hasChildNodes()

None

NodeList

length

item()

None

NamedNodeMap

length •

item()

None

Properties and methods of the document object

The following table details the properties and methods of the document object that are supported in Dreamweaver. A bullet (•) marks read‑only properties.

Property or method

Return value

nodeType

Node.DOCUMENT_NODE

parentNode

null

parentWindow

The JavaScript object that corresponds to the document’s parent window. (This property is defined in the Microsoft Internet Explorer 4.0 DOM, but is not part of DOM Level 1 or 2.)

childNodes

A NodeList that contains all the immediate children of the document object. Typically the document has a single child, the HTML object.

previousSibling

null

nextSibling

null

documentElement

The JavaScript object that corresponds to the html tag. This property is shorthand for getting the value of document.childNodes and extracting the HTML tag from the NodeList.

body

The JavaScript object that corresponds to the body tag. This property is shorthand for calling document.documentElement.childNodes and extracting the body tag from the NodeList. For frameset documents, this property returns the node for the outermost frameset.

URL

The file://URL for the document or, if the file has not been saved, an empty string.

getElementsByTagName(tagName)

A NodeList that can be used to step through tags of type tagName (for example, img, div, and so on).

If the tagName argument is “LAYER”, the function returns all LAYER and ILAYER tags and all absolutely positioned elements.

If the tagName argument is “INPUT”, the function returns all form elements. (If a name attribute is specified for one or more tagName objects, it must begin with a letter, which the HTML 4.01 specification requires, or the length of the array that this function returns is incorrect.)

getElementsById(Id)

Gets the element node with the specified id. Where id is a string containing the ID of the element to get.

var dom = dw.getDocumentDOM(); var contObj = dom.getElementById('content'); alert("The element with the id 'content' is a " + contObj.tagName);

getElementsByAttributeName(attrName)

A NodeList that can be used to step through elements with an attribute attrName (for example, all elements with the attribute "for"). Not part of DOM Level 1 or 2.

getElementById(id)

The HTML element with the specified ID.

hasChildNodes()

true

Properties and methods of HTML

The following table lists the properties and methods of HTML elements in Dreamweaver, along with their return values or explanations. A bullet (•) marks read-only properties.

Property or method

Return value

nodeType

Node.ELEMENT_NODE

parentNode

The parent tag. If this is the HTML tag, the document object returns.

childNodes

A NodeList that contains all the immediate children of the tag.

previousSibling

The sibling node immediately prior to this one. For example, in an HTML document the previousSibling for the body element is the head element.

nextSibling

The sibling node immediately following this one. For example, in an HTML document the nextSibling for the head element is the body element. (Any script, style, or meta tags in the head would be child nodes of the head element.)

tagName

The HTML tagName for the element, such as IMG, A, or DIV. The value returned is always in uppercase letters.

attrName

A string that contains the value of the specified tag attribute.The tag.attrName cannot be used if the attrName attribute is a reserved word in the JavaScript language (for example, class). In this case, use getAttribute() and setAttribute().

innerHTML

The source code that is contained between the opening tag and the closing tag. For example, in the code <p><b>Hello</b>, World!</p>, p.innerHTML returns <b>Hello</b>, World!. If you write to this property, the DOM tree immediately updates to reflect the new structure of the document. (This property is defined in the Microsoft Internet Explorer 4.0 DOM, but is not part of DOM Level 1 or 2.)

outerHTML

The source code for this tag, including the tag. For the previous example code, p.outerHTML returns <p><b>Hello</b>, World!</p>. If you write to this property, the DOM tree immediately updates to reflect the new structure of the document. (This property is defined in the Microsoft Internet Explorer 4.0 DOM, but is not part of DOM Level 1 or 2.)

getAttribute(attrName)

The value of the specified attribute if it is explicitly specified; null otherwise.

getTranslatedAttribute(attrName)

The translated value of the specified attribute or the same value that getAttribute() returns if the attribute’s value is not translated. (This property is not included in DOM Level 1; it was added to Dreamweaver 3 to support attribute translation.)

setAttribute(attrName, attrValue)

Does not return a value. Sets the specified attribute to the specified value example, img.setAttribute("src", "image/roses.gif").

removeAttribute(attrName)

Does not return a value. Removes the specified attribute and its value from the HTML for this tag.

getElementsByTagName(tagName)

A NodeList that can be used to step through child tags of type tagName (for example, IMG, DIV, and so on).

If the tagName argument is “layer”, the function returns all LAYER and ILAYER tags and all absolutely positioned elements.

If the tagName argument is “input”, the function returns all form elements. (If a name attribute is specified for one or more tagName objects, it must begin with a letter, which the HTML 4.01 specification requires, or the length of the array that this function returns is incorrect.)

getElementsByAttributeName(attrName)

A NodeList that can be used to step through elements with an attribute attrName (for example, all elements with the attribute "for"). Not part of DOM Level 1 or 2.

hasChildNodes()

A Boolean value that indicates whether the tag has any children.

hasTranslatedAttributes()

A Boolean value that indicates whether the tag has any translated attributes. (This property is not included in DOM Level 1; it was added to Dreamweaver 3 to support attribute translation.)

Properties and methods of text objects

Each contiguous block of text in an HTML document (for example, the text within a p tag) is represented by a JavaScript object. Text objects never have children. The following table describes the properties and methods of text objects that are taken from DOM Level 1 and used in Dreamweaver. A bullet (•) marks read‑only properties.

Property or method

Return value

nodeType

Node.TEXT_NODE

parentNode

The parent tag

child Nodes

An empty

previousSibling

The sibling node immediately prior to this one. For example, in the code <p>blah<br />blah</p>, the <p> tag has three child nodes (text node, element node, text node). The previousSibling of the third child is the <br /> tag; the previousSibling of the first child is null.

nextSibling

The sibling node immediately following this one. For example, in the code <p>blah<br />blah</p>, the nextSibling of the first child of the p tag is the <br /> tag; the nextSibling of the third child is null.

data

The actual text string. Entities in the text are represented as a single character (for example, the text Joseph &amp; I is returned as Joseph & I).

hasChildNodes()

false

Properties and methods of comment objects

A JavaScript object represents each HTML comment. The following table details the properties and methods of comment objects that are taken from DOM Level 1 and are used in Dreamweaver. A bullet (•) marks read-only properties.

Property or method

Return value

nodeType

Node.COMMENT_NODE

parentNode

The parent tag

childNodes

An empty NodeList array

previousSibling

The sibling node immediately prior to this one.

nextSibling

The sibling node immediately following this one.

data

The text string between the comment markers (<!-- and -->)

hasChildNodes()

false

The dreamweaver and site objects

Dreamweaver implements the standard objects that are accessible through the DOM and adds two custom objects: dreamweaver and site. These custom objects are widely used within the APIs and in writing extensions. For more information on the methods of the dreamweaver and site objects, see the Dreamweaver API Reference.

Properties of the dreamweaver object

The dreamweaver object has two read-only properties, which are described in the following list:

  • The appName property has the value "Dreamweaver".

  • The appVersion property has a value of the form "versionNumber.releaseNumber.buildNumber[languageCode] (platform)".

    As an example, the value of the appVersion property for the Swedish Windows version of Dreamweaver is "8.0.XXXX [se] (Win32)"; the value for the English Macintosh version is "8.0.XXXX [en] (MacPPC)".

    Note: You can find the version and build number by selecting the Help > About menu item.

The appName and appVersion properties were implemented in Dreamweaver 3 and are not available in earlier versions of Dreamweaver.

To find the specific version of Dreamweaver, check first for the existence of appVersion and then for the version number, as shown in the following example:

 if (dreamweaver.appVersion && dreamweaver.appVersion.indexOf('3.01') != -1){¬ 
    // execute code 
}

The dreamweaver object has a property called systemScript that lets you query the language of the user’s operating system. Use this property if you need to include special cases in your extension code for localized operating systems, as shown in the following example:

 if (dreamweaver,systemScript && (dreamweaver.systemScript.indexOf('ja')!=-1){¬ 
    SpecialCase }

The systemScript property returns the following values for localized operating systems:

Language

Value

Japanese

ja

Korean

ko

TChinese

zh_tw

SChinese

zh_cn

Operating systems for all European languages return 'en'.

The site object

The site object has no properties. For information about the methods of the site object, see the Dreamweaver API Reference.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy