Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

event.preventDefault() not stopping mailto links w/ gmail

I have a jQuery function with even.preventDefault() applied to a click on any element with the class 'editable'.

It's not preventing gmail from opening up it sweb interface to send an email, however. It works on systems where default mail behaviour is not set up (the one I was primarily testing on).. not sure about when it's run through Outlook or an actual mail application.

Is there some workaround for this?

$('.editable').not('video, img, textarea').click(function(event) { 
        event.preventDefault();
        loadEditor($(this));
    });

edit: I have also tried with event.stopPropagation(); but it is still going through.

like image 412
Damon Avatar asked Dec 05 '25 01:12

Damon


2 Answers

The gmail interface event handling is probably happening in-browser, so try calling event.stopPropagation too.

like image 88
Douglas Avatar answered Dec 06 '25 15:12

Douglas


try adding return false,

$('.editable').not('video, img, textarea').click(function(event) { 
        event.preventDefault();
        loadEditor($(this));
        return false;
    });

event.preventDefault() vs. return false

like image 31
Jayantha Lal Sirisena Avatar answered Dec 06 '25 14:12

Jayantha Lal Sirisena



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!