Mailto Gmail handler always opens mailto link in same tab, cant force it to new tab.
Hello, I would like some guidance regarding the settings of mailto handlers. Problem: when i click on mailto link for example <a href="mailto:vyzkumy@medea.cz" target… (přečíst více)
Hello, I would like some guidance regarding the settings of mailto handlers.
Problem: when i click on mailto link for example <a href="mailto:vyzkumy@medea.cz" target="_blank" rel="noopener">vyzkumy@medea.cz</a> when the gmail is set as default mailto handler, it doesnt respect target blank attribute and allways opens in the same tab. right click with open in new tab works, but i always forget it. thats not a solution for me.
goal: have a gmail as default mailto handler, but every mailto link to open in new tab, not the same.
unsuccessful attempts: tried tampermonkey with custom javascript code, that worked in chrome and edge, but seems to be ignored in firefox due to gmail handler possibly(?) 1st - add target blank attribute to every mailto link - didnt work 2nd - on click on mailto link, copy the link, open new tab and paste it. - didnt work
code example: // Get all anchor tags on the page const anchors = document.getElementsByTagName('a');
// Loop through each anchor tag for (let i = 0; i < anchors.length; i++) {
// Check if the href attribute starts with 'mailto:' if (anchors[i].getAttribute('href') && anchors[i].getAttribute('href').startsWith('mailto:')) {
// Add an event listener to the mailto link anchors[i].addEventListener('click', function(event) {
// Prevent the default behavior of the mailto link event.preventDefault();
// Get the mailto link const mailtoLink = this.getAttribute('href');
// Open the mailto link in a new tab window.open(mailtoLink, '_blank'); }); }
}
it seems that default firefox email handler block javascript or tampermonkey entirely.
fun fact: when firefox is set as windows default email handler, when you open mailto link anywhere else, it opens in firefox new tab. it only do net work for links opened directly in firefox.
is there any solution? i will be glad for any help.