LemmyX
LemmyX

Reputation: 137

target="_blank" not opening new tab with "mailto:" link

I have a link on my website where you click and it opens up your email and starts a new draft. However, I've been testing it, and it opens email in the same tab, which is kind of annoying because then you have to reopen the page. I have target="_blank", but it still doesn't open in a new tab.

<button class="navhome" onclick="window.location.href='mailto:[email protected]'" 
    target="_blank" style="background-color:rgb(0,255,0);
    border:none;
    color:white;
    padding:15px 32px;
    text-align:center;
    display:inline-block;
    font-size:16px;">Contact us</button>

Does target:"_blank" not work for buttons, or is it that I'm using mailto, which doesn't necessarily use a browser?

Upvotes: 1

Views: 2682

Answers (1)

AsyncBanana
AsyncBanana

Reputation: 37

You have to put a underscore before the name of the link type, like this: target = '_blank' or target = "_blank" EDIT: It is also because you can only have links in anchor tags like so <a href = "link.com" target = "_blank">Click to go somewhere</a>. Sorry for missing that.

Upvotes: 1

Related Questions