Search code examples
javascriptcross-browsermailto

Is there a way to tell if an end user will be able to handle <a href=“mailto:###”> links?


I'm trying to adapt to the situation in which a user has no email client installed (like in my case: i use opera's internal mail client, so if i click a mailto: link i internet explorer i won't get anything.))


Solution

  • At the moment it is not possible. The closest thing to an answer I ended up with this:

    <a id="mail-link" href="mailto:the@email.it" onclick="if (this.hasAttribute('data-clickedonce')) {this.setAttribute('href','mailform.php?to=the@email.it');} this.setAttribute('data-clickedonce','yes');">Send a Mail</a>
    

    The script embedded in the a tag changes the href on the second press. The theory is: if the user has no way to handle the mail protocol, nothing happens and he/she will certainly try to click the link another time.