In order to do this you need to attach the handler to a specific anchor on the page.  For operations like this it's much easier to use a standard framework like jQuery.  For example if I had the following HTML
HTML:
<a id="theLink">Click Me</a>
I could use the following jQuery to hookup an event to that specific link. 
// Use ready to ensure document is loaded before running javascript
$(document).ready(function() {
  // The '#theLink' portion is a selector which matches a DOM element
  // with the id 'theLink' and .click registers a call back for the 
  // element being clicked on 
  $('#theLink').click(function (event) {
    // This stops the link from actually being followed which is the 
    // default action 
    event.preventDefault();
    var answer confirm("Please click OK to continue");
    if (!answer) {
      window.location="http://www.continue.com"
    }
  });
});