I tried this with umpteen examples we see on the net. But I guess there is none that is simple and works on all browsers (IE 8 and above as well).
I am trying to simply open up Outlook window with mailto link.
<a href="#" name="emailLink" id="emailLink">Email</a>
JQuery:
$(function () {
$('#emailLink').on('click', function (event) {
alert("Huh");
var email = '[email protected]';
var subject = 'Circle Around';
var emailBody = 'Some blah';
window.location = 'mailto:' + email + '?subject=' + subject + '&body=' + emailBody;
});
});
Granted, I am a jQuery newbie. The above just doesn't work. It just flickers the browser but nothing opens. I guess this is because of window.location
.
Is there a simple solution? I want this to work in IE8 & above and in all browsers.
The body is generated automatically (in JSP).
href
is spelled wrong. also you select by id but the tag has no id – Ineslta'click'
and beforefunction
– Despinadespise