Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do mailto links in Chrome conflict with POST requests?

I'm not entirely sure the question is correct but here's the situation. I have a webpage with two POST requests, which are open for some time (the response isn't suppose to come right away) while I can be doing other things on the page. I also have a mailto link on the page. For some reason in Chrome, when I click that link, the two requests immediately return an error. I also noticed that the console in Chrome shows the mailto link as a GET request event (when it's clicked). What is going on here? Even if Chrome treats mailto links as requests, why should it conflict with any other requests on the page?

In Firefox the mailto link has zero affect on the requests, they just keep working and waiting on server response. Also, the link itself doesn't seem to be a request of any sort. BTW, the mailto opens up an Outlook message window (and that part works fine in Chrome, just the requests fail).

Also just in case, I'm using jQuery $.ajax to initiate the requests.

It was pointed out that perhaps Chrome treats a mailto link like a regular, at least in part, and so has some of the side effects. So then the question becomes how do I combine a mailto link with request on the page? I can't replace the link with a form.

like image 546
Ilia Draznin Avatar asked May 03 '11 13:05

Ilia Draznin


People also ask

Do mailto links work in Chrome?

If you want Chrome and Gmail to open mailto links for you by default, make sure Google Chrome is picked as the default client on either OS. In Firefox, you can also specify which client should handle mailto links. Click on the menu button -> Preferences.

Why mailto is not working in HTML?

If you are using Windows 7 or higher, then all you have to do is set the default email client. Check this in the control panel under Default Apps setting. Just click on the email client you want and you are all set. Show activity on this post.

Why are email links not opening in Chrome?

Google Chrome users may experience the mailto link not opening or it opens using an incorrect email client and/or browser. If you want to have mailto links open in the correct browser or email client , it's helpful to learn how with different browsers.

How do I enable mailto in Chrome?

Open Chrome settings. Select "Show advanced settings" and click on "Content settings" under "Privacy." Scroll down to "Handlers" and select "Manage handlers." Select "mail.google.com" as your mailto site.


1 Answers

I ran into this issue recently. This actually happens with mailto: or any other app URI in Chrome. The solution I used was to load the URL in an iframe:

$('body').append('<iframe id="mailto-launcher"></iframe>');
$('#mailto-launcher').get(0).contentWindow.location.href = 'mailto:?subject=test';

You can also style that iframe so that is it rendered off the page (using absolute positioning, etc). This will launch the mail client and still keep your document's AJAX requests alive.

like image 151
Neil Goodman Avatar answered Sep 27 '22 17:09

Neil Goodman