Javascript Mailto Not Working In Chrome Mobile Browser
mailto via javascript not working in mobile chrome browser window.location.href = 'mailto:linto.cet@gmail.com?subject=subject&body=body' is not working in mobile google chrome
Solution 1:
Chrome on Android is blocking the redirects to apps that are not made via a user gesture.
So via javascript it's not possible to redirect the user to the mail app since Chrome 40, only if you put it for example in a button href, that will work when user clicks the button.
You can read more in chromium forum
If you inspect the Chrome console you will a warning, something like: Navigation is blocked: mailto:?...
Solution 2:
I am posting an answer as this is possible.
Create a hidden from view / temporary link element and simulate the click.
var linkElement = document.createElement('a');
linkElement.style.visibility = 'hidden';
linkElement.style.position = 'absolute';
linkElement.href = 'mailto:linto.cet@gmail.com?subject=subject&body=body';
document.body.appendChild(linkElement);
and later when you want to trigger and open the mail client:
linkElement.click();
Post a Comment for "Javascript Mailto Not Working In Chrome Mobile Browser"