How to open the gmail app on your mobile phone

-4

I know that to open the maps is like this:

window.location = "geo:?q="+endereco;

To open the phone dial it looks like this:

 window.location = "tel:"+telefone1;

To open the message screen (sms):

window.location = "sms:"+telefone;

Now, how do I open the email?

    
asked by anonymous 17.12.2018 / 18:09

1 answer

1

Chrome on Android is blocking redirects for applications that are not made through a user gesture.

So, via javascript it is not possible to redirect the user to the email application, this from Chrome 40, only if you put it for example on a href button, it will work when the user clicks the button.

Here's a discussion on the subject in the Chrome forum.

If you inspect the element you will see a message like

  

Navigation is blocked: mailto:? ...

You can try to do it this way, as I mentioned before it's adding a href.

var email = document.createElement('a');
email.style.visibility = 'hidden';
email.style.position = 'absolute';
email.href = 'mailto:[email protected]?subject=subject&body=body';
document.body.appendChild(email);

And after that when you're done you can do that.

email.click();
    
17.12.2018 / 18:18