Solved

Need confirmation message for img/text link?

Posted on 2013-06-19
4
268 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 42

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 42

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now