I'd like to invoke a mailto link from JavaScript - that is I'd like a method that allows me to open the email client on the users PC, exactly as if they had clicked on a normal mailto link.
How can I do this?
I'd like to invoke a mailto link from JavaScript - that is I'd like a method that allows me to open the email client on the users PC, exactly as if they had clicked on a normal mailto link.
How can I do this?
You can use
window.location.href
here, like this:You can avoid the blank page issue discussed above by instead using .click() with a link on the page:
the working answer for me, tested in chrome, IE and firefox together with outlook was this
%0d%0a
is the new line symbol of the email body in a mailto link%20
is the space symbol that should be used, but it worked for me as well with normal spaceActually, there is a possibillity to avoid the empty page.
I found out, you can simply insert an iframe with the mailto link into the dom. This works on current Firefox/Chrome and IE (also IE will display a short confirm dialog).
Using jQuery, I got this: