Calling a Behavior from a Link
As seen earlier, you can use an event associated with an object to
execute a behavior. You can also call the function directly from a
hyperlink using the
javascript:
protocol followed by the name of the function to execute and its
associated parameters. An example of this technique is shown in Figure 16-9.
Figure 16-9. Calling JavaScript directly via a hyperlink
Note that the link field in Figure 16-9 (which
corresponds to the href
attribute) contains:
javascript:MM_goToURL('parent','testing.html');
This statement instructs the browser to execute the
MM_goToURL
function using the supplied parameters.
The effect is similar to triggering the Go To URL behavior with the
onClick
event.
An alternative technique for attaching a behavior to a text span is discussed under “About behaviors and text” under Help → Using Dreamweaver.
The next chapter covers timelines and behaviors associated with them.
Get Dreamweaver in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.