The best place to find jQuery plugins !

Welcome on myjqueryplugins,

the best jquery plugins library !

Add your jQuery plugin.

Connect it with GitHub and create your plugin Homepage.

Make known your plugin to the community or link it to your own website !

jQuery Confirm mailto : A plugin to confirm with users before opening any mailto link.

Tags :

Plugin rate :

Confirm with users before opening any link on the page through their default email client.

Implementation: 

Basic Usage:
- Make sure you have jQuery loaded properly.

1
<script src="http//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

-Include confirm.min.js or place the plugin code at the top of your javascript file (recommended).

1
!function(t){t.fn.confirmMailto=function(e){var n=t.extend({message:"Do you want to send an email to $to?",to:"href",callback:function(){},success:function(){},fail:function(){}},e),a=/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/gi,i=function(e){var i=n.message,c=n.to;if(c="href"==c?t(this).attr("href").match(a):"html"==c?t(this).html():c,i=i.replace("$to",c)==i?i+c:i.replace("$to",c),confirm(i)){n.success();var o=!0}else{e.preventDefault(),n.fail();var o=!1}return setTimeout(function(){n.callback(o)},1),o};return this.filter('[href^="mailto:"]').each(function(){t(this).bind("click",i)}),this}}(jQuery);

- Call the method on document load.

1
2
3
$(document).ready(function(){
        $('a').confirmMailto();
});

Advanced Usage:
- You can alternately call the method with the following options.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 $('a.advanced').confirmMailto({
        message:        'Are you cool enough to send an email to $to? ',
        to:             'html', // href/html
        success:        function(){
                                $('a.advanced').css('color','#3C3');
                        },
        fail:           function(){
                                $('a.advanced').css('color','#F66');
                        },
        callback:       function(result){
                                if(result){
                                        alert('Thank you!');
                                }else{
                                        alert('Boooo!');
                                }
                        }
}); 
Options: 
message
String
Default : Do you want to send an email $to? - Message to display in the confirmation dialog. $to is the recipient format.
to
String
Default : href - The format of the recipient in the dialog message. 'href' : email linked to in href attribute / 'html' : inner html of anchor tag.
success
Function
Called on successful confirmation, before redirection.
fail
Function
Called on failed confirmation.
callback
Function
Called after success/fail and after redirection.
Methods: 
confirmMailto
Function
Returns : jQuery object - Main call
Screenshots

Add new comment

To prevent automated spam submissions leave this field empty.

Plain text

  • Lines and paragraphs break automatically.
  • Allowed HTML tags: <p> <br> <br />

Informations

jQuery
>= 1.0
Browsers compatibility
Google ChromeIE 8IE 9Mozilla FirefoxOperaSafari
Fork it on github Comments [0]