Using JavaScript to Enhance LinksSometimes, you may want to perform some sort of action after the user clicks a link, but before the browser goes to the link's destination. A typical example would be when you want to put up an alert before the user goes to a particular page on your site, or to make it clear when the user leaves your site. In this example, we'll put up an alert dialog before continuing on to the ultimate destination. Script 2.12 shows the HTML, and Script 2.13 shows the small amount of changes we need to make to previous scripts. Script 2.12. The HTML, as usual, contains an id in the link tag that JavaScript can use.
Script 2.13. The link enhancement script.
To enhance links:
Tips
|