I am developing a website.
What does mailto:
open in if there is no email client (like Outlook, Thunderbird, etc.)?
It works on my computer, which has Outlook, but what if one wants mailto:
to open in, say, gmail.com?
What do I need to put in the mailto:
statement for that to happen?
Email (mailto) links are used for linking directly to an email address, which will automatically launch an email browser when the link is clicked.
Mailto HTML Links Explained. HTML is nearly as old as the internet, and so is one of its most common schemes: mailto. And, even though so many things have changed since then, good ol' mailto is still widely used and taught in HTML courses all around the world.
In the message, select the text or picture that you want to display as the link. On the Insert tab, click Link or Hyperlink. Under Link to, click E-mail Address. Either type the email address that you want in the E-mail address box, or select an email address in the Recently used e-mail addresses list.
Make Gmail the default email program to open email links in Chrome Browser. Settings. Go to the Privacy and security section. At the top, make sure Allow sites to ask to become default handlers for protocols (recommended) is turned on.
As a web developer you don't have any control over the software that a user chooses to open their email, since it's handled by that user's web browser settings, or the OS. If a user has no email program installed on their machine and no operation defined for "mailto" links in their browser, nothing would happen.
The following solution works for me:
(function($)) {
$('a[href^=mailto]').each(function() {
var href = $(this).attr('href');
$(this).click(function() {
var t;
var self = $(this);
$(window).blur(function() {
// The browser apparently responded, so stop the timeout.
clearTimeout(t);
});
t = setTimeout(function() {
// The browser did not respond after 500ms, so open an alternative URL.
document.location.href = '...';
}, 500);
});
});
})(jQuery);
For more info see: https://www.uncinc.nl/articles/dealing-with-mailto-links-if-no-mail-client-is-available
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With