beautypg.com

Dreamweaver.getdocumentdom() – Adobe Dreamweaver API Reference CS5 User Manual

Page 261

background image

256

DREAMWEAVER API REFERENCE

Document

Last updated 8/27/2013

dreamweaver.getDocumentDOM()

Availability
Dreamweaver 2.

Description
Provides access to the objects tree for the specified document. After the tree of objects returns to the caller, the caller
can edit the tree to change the contents of the document.

Arguments
{sourceDoc}

The sourceDoc argument must be

"document"

,

"parent"

,

"parent.frames[number]"

,

"parent.frames['frameName']"

, or a URL. The

sourceDoc

value defaults to

"document"

if you do not supply

a value. These argument values have the following meanings:

The

document

value specifies the document that has focus and contains the current selection.

The

parent

value specifies the parent frameset (if the currently selected document is in a frame).

The

parent.frames[number]

and

parent.frames['frameName']

values specify a document that is in a

particular frame within the frameset that contains the current document.

If the argument is a relative URL, it is relative to the extension file.

Note: If the argument is

"document"

, the calling function must be the

applyBehavior()

,

deleteBehavior()

,

objectTag()

functions, or any function in a command or Property inspector file that can perform edits to the document.

Returns
The JavaScript document object at the root of the tree.

Examples
The following example uses the

dreamweaver.getDocumentDOM()

function to access the current document:

var theDOM = dreamweaver.getDocumentDOM("document");

In the following example, the current document DOM identifies a selection and pastes it at the end of another
document:

var currentDOM = dreamweaver.getDocumentDOM('document');

currentDOM.setSelection(100,200);
currentDOM.clipCopy();
var otherDOM = dreamweaver.openDocument(dreamweaver.¬
getSiteRoot() + "html/foo.htm");
otherDOM.endOfDocument();
otherDOM.clipPaste();

Note: The

openDocument()

argument is used because

DOM

methods normally operate only on open documents. Running

a function on a document that isn’t open causes a Dreamweaver error. The

DOM

methods that can operate only on the

active document or on closed documents indicate this fact in their descriptions.