I am having a problem using Internet Explorer 8 (IE8) to open mailto links with long messages.
After the user clicks on the link, IE changes to an about:blank page and never completes the call to outlook to create an email
Here's an example:
<a href="mailto:[email protected]?subject=123456789&body=111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111">mailto fails in IE8</a>
If I shorten the list of 1's, the email is generated and can be sent.
Is this a known IE issue? What are the limitations?
If mailto links don't open for you the way they should, a quick look at the system or browser settings should do the job. In Windows, head to Settings -> Apps -> Default apps. Scroll down and pick “Choose default apps by protocol” from the menu. For 'Mailto', choose the client of your choice.
subject=<subject> to the mailto tag. For example, the complete tag would look similar to the example below. You can also add body text by adding &body=body to the end of the tag, as shown in the example below. You can also include &cc= or &bcc= to fill out the CC and BCC fields.
The Mailto format does not support HTML code emails. Outlook was used at 2003, but to become compliant with the mailto: standard they removed that functionality. But you can Use %0D%0A for a line break in HTML body.
I never could get the location.href = mailtoHref
hack to work. However, I have found that following works.
$('body').append($('<iframe id="mailtoHack" src="' + mailtoHref + '"/>');
$('#mailtoHack').remove();
EDIT
Here is a way to do it without jQuery:
function mailtoHack(href) {
var iframeHack;
if (href.indexOf("mailto:") === 0) {
iframeHack = document.createElement("IFRAME");
iframeHack.src = href;
document.body.appendChild(iframeHack);
document.body.removeChild(iframeHack);
}
}
And, for good measure, here is a Knockout custom binding usable as data-bind="mailto: foo"
:
ko.bindingHandlers.mailto = {
init: function (element, valueAccessor) {
ko.utils.registerEventHandler(element, "click", function (e) {
var href = ko.unwrap(valueAccessor()), iframeHack;
if (href.indexOf("mailto:") === 0) {
iframeHack = document.createElement("IFRAME");
document.body.appendChild(iframeHack);
document.body.removeChild(iframeHack);
} else {
e.preventDefault();
}
});
}
};
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