JohnnyBizzle
JohnnyBizzle

Reputation: 979

To target=_blank or not to target=_blank, that is the question!

Should links to external sites set target=_blank? E.g. I am on www.acme.net and have a link to www.otherplace.net, should that link be:

<a href='http://www.otherplace.net' target='_blank'>otherplace's website</a>

or:

<a href='http://www.otherplace.net'>otherplace's website</a>

I was under the impression that using _blank to sites outside your domain was best practice, but now I am being told otherwise.

Upvotes: 30

Views: 11160

Answers (9)

Jan Lachnitt
Jan Lachnitt

Reputation: 81

TL;DR: Don't use target="_blank".

Nowadays this question is perhaps less pressing yet still relevant. I've read some resources and given it a thought. So:

Consider we have an article (scientific, journalistic,...) with references to external sources. It seems reasonable to open the references in separate tabs, because the reader probably doesn't really want to leave the article when checking an external resource.

Now consider two types of users: advanced users, who know how to open a link in a new tab, and other users, who don't know that.

Advanced users will probably do something like Ctrl+Shift+Click to open the link in a new tab. In this case, target="_blank" has no effect.

Other users don't manually open links in new tabs, so they are probably used to use the Back and Forward buttons. Without target="_blank", the external resource will be opened in the existing tab, and the user will then probably use the Back button to return to the article. Modern browsers automatically scroll to the position where the page was left, so there is hardly any annoyance to the user. With target="_blank", a new tab will be opened, which the user may not even notice. When they want to go back to the article, they find the Back button not working, which may cause various levels of confusion.

Conclusion: Although opening external links in separate tabs is reasonable, the decision should be left to the user.

BTW, Stack Overflow doesn't use target="_blank" for external links either.

Exception: target="_blank" is helpful when the page is doing something that shouldn't be interrupted (media playback, form filling, and the like).

References:

Upvotes: 1

AMG
AMG

Reputation: 29

Just don't do it. Using target attributes with links presents complications for assistive technology users who may not know another tab has opened. It becomes a bad experience for these users when the back button does not work in the new tab to take them back to the page they started on. This practice can also be disorienting to people with cognitive disorders. It is best to let users decide where links will open.

Upvotes: 4

tking
tking

Reputation: 11

Just make two buttons for your users: One to open in new tab, and another to abandon the current page in favor of the linked page.

[ www.google.com ] [Open Google in place of THIS page]

Upvotes: 1

Pacerier
Pacerier

Reputation: 89583

You need to predict what your users want. Use target="_blank" if you expect your users will want to stay on the site.

For example if a blog post has a link in the middle of the post, it makes sense to open that link in a new tab since you are expecting the reader to return to the page and continue reading.

Some people argue that the reader could simply click "Back" when they wanted to come back to the page,

But new webpages will have more links to webpages that have more links, what happens is that the reader has to "Back" a couple of times to get back to your blog post. Either that, or he ends up "lost" in the myriad of linked pages and couldn't come back to your blogpost (you can be sure that no one wants to open History and find your page again when they are "lost", unless there is a big incentive to coming back to your page).

Upvotes: 1

CJM
CJM

Reputation: 12016

Some web idealists will state that you should allow the user to make their own choices when it comes to navigation - I have a lot of sympathy with this view. As web developers, we shouldn't be forcing such decisions on our visitors.

However, I also know that businesses often want to 'retain control' and so insist on spawning a new tab/window for external sites. An I understand this too - It's a very practical approach, particularly when you consider that how many users don't know how to control their own UA.

I often tend to steer a middle course between the two, by adding an image (I'm sure you will have seen many in your time) that indicates which links are external, and a note to indicate that external links will open in a new tab/window.

Not quite as 'pure' as the first option, but at least it is clear to the user how the site will behave.

Upvotes: 18

Antony Delaney
Antony Delaney

Reputation: 1168

found this on the w3c site

Checkpoints in this section:

•10.1 Until user agents allow users to turn off spawned windows, do not cause pop-ups or other windows to appear and do not change the current window without informing the user. [Priority 2] Content developers should avoid specifying a new window as the target of a frame with target="_blank".

More info here

the question you need to ask your client is "To what priority level are you aiming to achieve?"

Upvotes: 13

mare
mare

Reputation: 13083

It might also be worth to mention that using target attribute is not xhtml valid. I do usually open links in external window or tab because I see that most regular users (not the advanced ones) want it that way so that they can always get back to the site they were on - usually they would go deep into the other site and then it become unfriendly for them having to click back multiple times.

So in terms of usability I think that there's more users that don't use special techniques to manually open links in new window/tab.

With regards to the xhtml validation, you might want to decorate your links with rel="external" or some similar word then use this JS function to handle new window open. I did it like this 99% of time in the last few years.

function externalLinks() {
    if (!document.getElementsByTagName) return;
    var anchors = document.getElementsByTagName("a");
    for (var i = 0; i < anchors.length; i++) {
        var anchor = anchors[i];
        if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
            anchor.target = "_blank";
    }
}

/**
    DOCUMENT LOAD
**/
$(document).ready(function () {
    /** 
        external links
    **/
    externalLinks();
....

Upvotes: 3

amaseuk
amaseuk

Reputation: 2155

As it is a governmental website, this is a tricky question. I regularly see disclaimers for external sites on these type of sites. I don't know if this is a standard or not.

I think the answer is probably down to your own opinion, which should probably be based on usability and integrity.

Upvotes: 0

Mike G
Mike G

Reputation: 4793

I think it totally depends on your use case.

If you are opening a site in another domain and need to keep your site open, and I think in most cases you do, then use target='_blank'.

As a user, I find it annoying when I click on a link to another domain and it moves me from the original domain. Of course, using ctrl+click in most browsers is a way to defend against this - but why make the user do more work?

Upvotes: 4

Related Questions