Search code examples
htmliosgoogle-chromesafarimailto

href mailto and iOS safari


Upon trying a regular mailto element on my html, I noticed that one needs to keep pressing the link in iPhone Safari to be prompted to send a message. As suggested in a previous question, I tried adding target="_blank", as follows: <a href="mailto:[email protected]" target="_blank">Hi</a>

This solves the issue on iPhone (one click opens an email draft). However, this leaves a blank page open in Chrome when using desktop. It there a way to keep the single-click-draft functionality for Iphone without otherwise opening a blank page from desktop?


Solution

  • Instead of simply using an anchor element have you tried using the <form action=""> element to handle the mailto URL? While this is traditionally used to organize/collect data to send server-side, I've found it's useful to flatten usage for compatibility sake.

        <form action="mailto:[email protected]" method="get">
          <button style="background:none; border:none;" type="submit">Hi</button>
        </form>