Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  2] [ 1]  / answers: 1 / hits: 34875  / 10 Years ago, mon, september 29, 2014, 12:00:00

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).


More From » jquery

 Answers
58

here's working solution:



<a href=# name=emailLink id=emailLink>Email</a>


and the function:



$(function () {
$('#emailLink').on('click', function (event) {
event.preventDefault();
alert(Huh);
var email = '[email protected]';
var subject = 'Circle Around';
var emailBody = 'Some blah';
window.location = 'mailto:' + email + '?subject=' + subject + '&body=' + emailBody;
});
});

[#69296] Friday, September 26, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ryanulyssesb

Total Points: 91
Total Questions: 105
Total Answers: 102

Location: England
Member since Tue, Sep 8, 2020
4 Years ago
ryanulyssesb questions
Sat, Mar 20, 21, 00:00, 3 Years ago
Mon, Sep 14, 20, 00:00, 4 Years ago
Mon, Mar 9, 20, 00:00, 4 Years ago
Sun, Jul 7, 19, 00:00, 5 Years ago
;