Question

Is there a way with javascript to automatically have the page look for any mailto links and then have it fire off an alert when a user clicks on the mailto link?

I currently have this:

HTML:

<a href="mailto:nachomomma@notyourdomain.com">Email Link</a>

Javascript:

$(document).on('click','mailto',
function() {
alert('This is some alert text');
});

But that doesn't seem to work. Not too sure if I am going about this the correct way or if it's even possible.

Was it helpful?

Solution

You need to use an actual selector, such as a[href^="mailto"]

OTHER TIPS

make like this

 $(document).ready(function() {
              $("a[href^='mailto:']").click(function(){
                          alert('This is some alert text');
                      });
          });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top