J'ai un bouton qui déclenche la fonction javascript suivante:
function sendEmail() { var mail = 'mailto:[email protected]'; location.href = mail; };
Dans Chrome, cette fonction déclenche un HTTP GET à 'mailto: [email protected]', mais le HTTP GET a un statut "annulé" dans l'onglet Inspect Element Network et le client de messagerie n'est pas ouvert.
Dans IE, le client de messagerie ne s'ouvre pas non plus.
Comment puis-je ouvrir le client de messagerie?
Ça marche pour moi. Mais vous pouvez essayer ceci
function sendEmail() { var mail = 'mailto:[email protected]'; var a = document.createElement('a'); a.href = mail; document.body.appendChild(a); // Add to the DOM a.click(); document.body.removeChild(a); // Remove it back };