Solved

Need confirmation message for img/text link?

Posted on 2013-06-19
4
279 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer…
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
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)

738 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