?
Solved

Need confirmation message for img/text link?

Posted on 2013-06-19
4
Medium Priority
?
284 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 2000 total points
ID: 39261616
<a href=(....) onclick="return confirm('Are you sure?');">
0
 
LVL 45

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 45

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn how to dynamically set the form action using jQuery.
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)
Suggested Courses
Course of the Month15 days, 5 hours left to enroll

840 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