Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mailto link not working in chrome extension popup

This issue drove me nuts for 2 days. I made a simple chrome extension which calls a server-side program that returns HTML that I then stuff into a div in the popup. It was all fine, except for the simple anchor link containing a "mailto:[email protected]" href. An email message composition window would not pop up.

Workaround: Add target="_blank" attribute

I would like to know why this is necessary.

like image 987
virtualsue Avatar asked Jul 08 '10 10:07

virtualsue


2 Answers

It might have something to do with extensions running in separate processors from the browser, and therefore a target attribute is needed so that a new tab/window can be opened... there are some websites that don't work when displayed inside extension popups for this reason, because the extension frame won't navigate to certain pages...

like image 135
David Avatar answered Oct 04 '22 13:10

David


I know this is an old question, but I ran into a similar situation. I had to send an email, but I had to do it with a button instead of a link and had to finagle this:

function sendEmail(){
    var mail = 'mailto:[email protected]?subject=Subject&body=Body';
    var newWin = window.open(mail);
    setTimeout(function(){newWin.close()}, 100);
}

It's not ideal, because it opens a new window that's visible to the user instead of doing it instantly. In fact, my first attempt was this (which works in an HTML file, but doesn't work in my extension):

function sendEmail(){
    var mail = 'mailto:[email protected]?subject=Subject&body=Body';
    window.open(mail).close();
}

Not sure why adding a timer makes it work in this instance as opposed to just doing it like in a regular HTML file, but that worked for me so I thought I'd share.

like image 40
Paul Nelson Baker Avatar answered Oct 04 '22 15:10

Paul Nelson Baker