User Guide

Behavior functions 371
Description
Gets the DOM object that corresponds to the tag to which the behavior is being applied. This
function is applicable only in Behavior action files.
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 the Behaviors panel is being used to edit a behavior in a timeline
When the currently executing script is invoked by dreamweaver.popupAction()
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 of an action file
Example
The dreamweaver.getBehaviorElement() function can be used in the same way as
dreamweaver.getBehaviorTag() to determine whether the selected action is appropriate for the
selected HTML tag, except that it gives you access to more information about the tag and its
attributes. As shown in the following example, 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 as part of the function that initializes the user interface for
the Parameters dialog box:
function initializeUI(){
var theTag = dreamweaver.getBehaviorElement();
var CANBEAPPLIED = (theTag.tagName == "A" && ¬
theTag.getAttribute("HREF") != null && ¬
theTag.getAttribute("TARGET") == null);
if (CANBEAPPLIED) {
// display the action UI
} else{
// display a helpful message that tells the user
// that this action can only be applied to a
// hyperlink without an explicit target]
}
}
000_DW_API_Print.book Page 371 Wednesday, July 20, 2005 11:58 AM