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
I never could get the location.href = mailtoHref hack to work. However, I have found that following works.
$('body').append($('');
$('#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();
}
});
}
};