SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 1944 | Next

Joseph W. Lowery

"Dreamweaver CS3 Bible"


The event specification takes place in the canApplyBehavior() function. Usually, this function returns
either true or false, depending on whether the proper conditions for implementing the behavior have
been met. If, however, the conditions have been met and you want to specify an event to use, you can set
canApplyBehavior() to return a string of acceptable events.
In the following example, the page is inspected. If an AP element is found, the default event is overridden in
favor of onKeyDown:
function canAcceptBehavior() {
var nameArray = dreamweaver.getObjectRefs(???NS 4.0???,???document???,???LAYER???);
if (nameArray.length > 0) {
BC 55
Creating a Behavior
return ???onKeyDown???;
}
else {
return false;
}
}
It??™s also possible to specify a series of preferred events, in reverse order of preference, like this:
return ???onKeyDown, onKeyPress, onKeyUp???;
If one event handler is not available??”perhaps because the user specified an older browser??”the next is
selected.
Returning a value
Most event handlers don??™t require a return value to be implemented, but some, such as onMouseOver and
onMouseOut, do. Generally, Dreamweaver behaviors don??™t take this into account, but you can by declaring
a special variable, document.MM_returnValue.


Pages:
1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946