-2

I'm trying to open mail on click in js. I'm using mailto, but in chrome you need to change the handlers settings to make it work.

My question is can I make some sort of popup that ask for persmission and changes this setting to others?

PS: to give permision for me I only found this way:

  1. Open Gmail in Chrome and click the Protocol Handler icon overlapping-diamonds in your browser's address bar.
  2. When prompted to "Allow Gmail to open all email links?", select "Use Gmail," and click "Done."

EDIT

My code to send the mail

$("#applyText").click(function(){    
    var email = 'mail@gmail.com';
    var subject = 'Hire me im a genius';
    var emailBody = 'Hi Sample,';
    document.location = "mailto:"+email+"? 
    subject="+subject+"&body="+emailBody;
});
Krzysztof Janiszewski
  • 3,763
  • 3
  • 18
  • 38
PauBlanes
  • 11
  • 4

1 Answers1

0

this is browser settings specific, ie. it will behave differently depending on the user's browser settings. The user can change how mailto: links behave in chrome by visiting chrome://settings/handlers, or Chrome Settings->Content Settings->Manage Handlers...

This is an answer to that question.

So to answer your question
No it is not possible because this is browser settings.

But most browsers should open it without a problem. For me this works properly.

By the way, you have some minor mistakes in your code.

Here is an working example

$("#applyText").click(function() {
  var email = 'mail@gmail.com';
  var subject = 'Hire me im a genius';
  var emailBody = 'Hi Sample,';
  document.location = "mailto:" + email + "?subject=" + subject + "&body=" + emailBody;
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<button id="applyText">Click</button>
Krzysztof Janiszewski
  • 3,763
  • 3
  • 18
  • 38