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

Page 319

Advertising
background image

314

DREAMWEAVER API REFERENCE

Page content

Last updated 8/27/2013

Arguments
None.

Returns
A DOM object or a

null

value. This function returns a

null

value under the following circumstances:

When the current script is not executing within the context of the Behaviors panel

When

dreamweaver.popupAction()

starts the currently executing script

When the Behaviors panel is attaching an event to a link wrapper and the link wrapper does not yet exist

When this function appears outside an action file

Example
The

dreamweaver.getBehaviorElement()

function can be used in the same way as

dreamweaver.getBehaviorTag()

” on page 314 to determine whether the selected action is appropriate for the selected

HTML tag. The difference is that it gives you access to more information about the tag and its attributes. If you write
an action that can be applied only to a hypertext link (

A HREF

) that does not target another frame or window, you can

use the

getBehaviorElement()

function. You can use the getBehaviorElement() function as part of the function that

initializes the user interface for the Parameters dialog box. It is shown in the following example:

function initializeUI(){

var theTag = dreamweaver.getBehaviorElement();
var CANBEAPPLIED = (theTag.tagName == "A" && ¬
theTag.getAttribute("HREF") != null && ¬
theTag.getAttribute("TARGET") == null);
if (CANBEAPPLIED) {

// display the action user interface

} else{

// display a helpful message that tells the user
// that this action can only be applied to a
// link without an explicit target]

}

}

dreamweaver.getBehaviorTag()

Availability
Dreamweaver 1.2.

Description
Gets the source of the tag to which the behavior is being applied. This function is applicable only in action files.

Arguments
None.

Returns
A string that represents the source of the tag. This is the same string that passes as an argument (HTMLelement) to the

canAcceptBehavior()

function. If this function appears outside an action file, the return value is an empty string.

Advertising