<p>A pattern that's started to show up a lot in one of the web apps I'm working are links that used to just be a regular a-tag link now need a popup box asking "are you sure?" before the link will go.  (If the user hits cancel, nothing happens.)</p>

<p>We've got a solution that works, but somehow we're a web app shop without a Javascript expert, so I'm left with this crawling feeling like there's a better way to get the job done.</p>

<p>So, JS experts, what's the most standards-compliant, cross-browser way to get this done?</p>

<p>(For the record, this is already a site that requires JS, so no need to have a "non-JS" version.  But, it does need to work in any and all reasonably modern browsers.)</p>

<p>(Also, for bonus points it would be nice if people with JS turned off didn't have the links  work, rather than bypassing the confirm box.)</p>

Here's how we've been doing it:
```
```
<a href="#" onClick="goThere(); return false;">Go to new page</a>`

function goThere() 
{ 
   if( confirm("Are you sure?") ) 
    { 
       window.location.href="newPage.aspx"; 
    } 
}
```
```
(EDIT: Code reformatted to avoid horizontal scroll)