The Dreamweaver DOM

 < Day Day Up > 

The Dreamweaver DOM contains a subset of objects, properties, and methods from the World Wide Web Consortium (W3C) (www.w3.org/TR/REC-DOM-Level-1/) DOM Level 1, 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 DIV and SPAN objects)

child objects by name

 nodeType • parentNode • childNodes • documentElement • body • URL • parentWindow • 

 getElementsBy TagName() hasChildNodes() 

onLoad

all tags/elements

 nodeType • parentNode • childNodes • tagName • attributes by name innerHTML outerHTML 

 getAttribute() setAttribute() removeAttribute() getElementsByTagName() 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 math number object string regexp 

Matches Netscape Navigator 4.0

Matches Netscape Navigator 4.0

None

text

 nodeType • parentNode • childNodes • data 

hasChildNodes()

None

comment

 nodeType • parentNode • childNodes • 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 taken from DOM Level 1 and used 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 not included in DOM Level 1; however, Microsoft Internet Explorer 4.0 supports it.)

childNodes •

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

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 tag argument is LAYER, the function returns all LAYER and ILAYER tags and all absolutely positioned DIV and SPAN tags.

If the tag 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.)

hasChildNodes()

true


Properties and methods of HTML tag objects

Every HTML tag is represented by a JavaScript object. Tags are organized in a tree hierarchy, where tag x is a parent of tag y, if y falls completely within x's opening and closing tags (<x>x content <y>y content</y> more x content.</x>). For this reason, your code should be well-formed.

The following table lists the properties and methods of tag objects 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.

tagName •

The HTML name for the tag, such as IMG, A, or BLINK. This value always returns in uppercase letters.

attrName

A string that contains the value of the specified tag attribute. 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 not included in DOM Level 1, but Internet Explorer 4.0 supports it.)

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 not included in DOM Level 1, but Internet Explorer 4.0 supports it.)

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: for 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 tag argument is LAYER, the function returns all LAYER and ILAYER tags and all absolutely positioned DIV and SPAN tags.

If the tag 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.)

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

childNodes •

An empty NodeList

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

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 8 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. You might want to check that the user of your extension has Dreamweaver version 3 or later by checking for the existence of the appVersion or appName property.

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.

     < Day Day Up > 


    Developing Extensions for Macromedia Dreamweaver 8
    Developing Extensions for Macromedia Dreamweaver 8
    ISBN: 0321395409
    EAN: 2147483647
    Year: 2005
    Pages: 282

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net