Link to home
Start Free TrialLog in
Avatar of sabecs
sabecs

asked on

Need confirmation message for img/text link?

Hi,
What is the best way to include a popup confirmation message for the link below?

Thanks,

Andrew

<a href="mysql_to_excel.php" target="_blank" id="save_to_excel">
<img src="/images/excel_icon.png" alt="Save to Excel" width="18" height="18" border="0" />Save to Excel
</a>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of svenove
svenove
Flag of Norway image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Chris Stanyon
Using jQuery, you'd do something like this:

$('#save_to_excel').click(function(e) {
     if (!confirm("Are you sure?")) {
          //'Cancel' was clicked, so stop the link from being followed
          e.preventDefault();
     }
})

Open in new window

Avatar of sabecs
sabecs

ASKER

Thanks svenove, that's perfect... cheers.  Andrew
FYI - The modern, best practice approach to Javascript is to keep it un-obtrusive - i.e out of the HTML!!