Sometimes, you may want to perform some sort of action after the user clicks a link, but before the browser loads the new page. 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.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> ...