Solved

Need confirmation message for img/text link?

Posted on 2013-06-19
4
276 Views
Last Modified: 2013-06-21
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

0
Comment
Question by:sabecs
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
svenove earned 500 total points
ID: 39261616
<a href=(....) onclick="return confirm('Are you sure?');">
0
 
LVL 43

Expert Comment

by:Chris Stanyon
ID: 39261918
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

0
 

Author Closing Comment

by:sabecs
ID: 39264737
Thanks svenove, that's perfect... cheers.  Andrew
0
 
LVL 43

Expert Comment

by:Chris Stanyon
ID: 39265291
FYI - The modern, best practice approach to Javascript is to keep it un-obtrusive - i.e out of the HTML!!
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question