Javascipt or jQuery "Are you sure?" dialog for <A> link?

Posted by Andrew Tomazos - Fathomling on Stack Overflow See other posts from Stack Overflow or by Andrew Tomazos - Fathomling
Published on 2012-09-21T13:14:06Z Indexed on 2012/09/21 15:38 UTC
Read the original article Hit count: 171

Filed under:
|
|

I have a link in my HTML:

<a href="/DoSomethingDangerous">do something dangerous</a>

Visiting the DoSomethingDangerous link causes a not easily reversable action to occur.

So after the link is clicked on I would like a dialog box (eg "Are you sure?" "OK" "Cancel") to be displayed and if the user clicks Cancel the link is not visited and the browser remains at the same page.

What is the cleanest technique using either Javascript or jQuery to implement this?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery