Triggering a Script
Sometimes you won’t want a script to run until the visitor does something to trigger it. For example, perhaps you want to run a script when the visitor mouses over a particular picture or link, or when a page is loaded. These actions—mousing over or loading a page—are called intrinsic events. There are currently 18 predefined intrinsic events. You can use them as triggers to determine when a script will run.
To trigger a script:
Create the (X)HTML tag that the intrinsic event depends on (Figure 19.6).
Figure 19.6. First, create the (X)HTML tag that the intrinsic event depends on. In this case, I want the script to occur when a visitor clicks the link. Therefore, I have to start with the link tag.
Within the tag ...
Get HTML, XHTML, & CSS, Sixth Edition: Visual QuickStart Guide 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.