Dreamweaver provides the following functions to facilitate inserting Spry widgets.

dom.addJavaScript()

Availability

Dreamweaver CS3.

Description

This function tells Dreamweaver to insert a JavaScript block either in the head or in the body. If the location is inside the body, the JavaScript block is inserted immediately before the </body> tag. If the document already has a JavaScript block there, Dreamweaver does not insert a new <script> tag, but appends "code" to the content of the <script>.

Arguments

code, insideHead

  • The code argument is a string containing the JavaScript code to be inserted into the page

  • The insideHead argument is a Boolean value that indicates whether to insert the JavaScript block in the head or in the body. The default is true, which inserts the code in the head. If false, the code is inserted in the body immediately before the </body> tag. This argument is optional.

Returns

Nothing.

Example

 function objectTag() 
{ 
    . 
    . 
    . 
    var dom = dw.getDocumentDOM(); 
    var id = dwscripts.getUniqueId("accordion"); 
    var code = "new Accordion('" + id + "',250,{duration:200,step:20})"; 
    dom.addJavaScript(code, false); 
      
    return retVal; 
}

dom.copyAssets()

Availability

Dreamweaver CS3, and updated in CS4.

Description

An extension author can use this API to copy external dependent files to the site of the user. The author can also add the necessary file references into the head of the page.

Arguments

assetArray

An array of JavaScript objects. Each JavaScript object has srcURL, destURL, referenceType, useDefaultFolder, and documentRelativefields.

  • The srcURL argument is a path to the asset, expressed as a file://URL.

  • The destURL argument is a relative path specifying the location to copy the asset to. What destURL is relative to depends on the value of useDefaultFolder. If useDefaultFolder is true, the path is relative to the default Asset folder. If useDefaultFolder is false, the path is relative to the site root. If the site is not defined, the path is relative to the document. See the useDefaultFolder description.

  • The referenceType argument is necessary for the extension author to insert a file reference into the head. The valid values for referenceType are as follows:

    • link to insert a LINK tag for an external CSS file

    • import to insert a STYLE tag with @import

    • javascript to insert a SCRIPT tag with type=text/javascript

    • vbscript to insert a SCRIPT tag with type=text/vbscript

    • "" not to insert a reference in the head

  • The useDefaultFolder argument is a Boolean value that indicates whether the path specified in destURLis relative to the default Assets folder. When the value is false, meaning that this property is not set, destURL is assumed to be relative to the site root. If the site is not defined, destURL is assumed to be relative to the document. The default value of this argument is false.

  • The documentRelative argument is a Boolean value. The default value is false. When this parameter is false, the assets are copied to the folder specified in destURL relative to the site root, when the file is saved in a site. If the value is true, then the assets are copied to the path specified in destURL relative to the document.

Returns

An array of strings that are expressed as file://URLs. Each string represents a file that was included in the head of the document through a script or a link tag.

Example

 function objectTag() 
{ 
    . 
    . 
    . 
    var dom = dw.getDocumentDOM(); 
    var assetList = new Array(); 
    var assetInfo = new AssetInfo("Objects/Ajax/Accordion.css",          
                                 "Objects/Ajax/Accordion.css", 
                                 "Accordion.css", "link"); 
    assetList.push(assetInfo); 
    assetInfo = new AssetInfo("Objects/Ajax/Accordion.js", "Accordion.js", 
                             "javascript"); 
    assetList.push(assetInfo); 
    assetInfo = new AssetInfo("Objects/Ajax/Images", "Images", ""); 
    assetList.push(assetInfo); 
    dom.copyAssets(assetList); 
    return retVal; 
}

dom.getDefaultAssetFolder()

Availability

Dreamweaver CS3.

Description

Gets the default asset folder of the document.

Arguments

None.

Returns

A string that is the default asset folder name.

Example

 function objectTag() 
{ 
. 
. 
. 
var defaultAssetFolder = dom.getDefaultAssetFolder(); 
. 
. 
. 
return retVal; 
}

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