<commit_before>---
layout: post
title: "Making external links open in a new browser tab"
date: 2015-02-04T19:25:52+05:45
excerpt: "Learn about best web practices and how to open new links in a new window."
---

Take note that according to most usability experts, opening links in a new browser tab is considered bad practice.

> Avoid spawning multiple browser windows if at all possible -- taking the "Back" button away from users can make their experience so painful that it usually far outweighs whatever benefit you're trying to provide. One common theory in favor of spawning the second window is that it keeps users from leaving your site, but ironically it may have just the opposite effect by preventing them from returning when they want to.
>
> <cite><a href="http://www.snyderconsulting.net/article_7tricks.htm#7">Second browser windows</a>, <em>Seven tricks that Web users don't know</em></cite>

If you would still like to open external links in a new browser tab/window, follow these instructions.

### Table of contents

* [Open link in a new browser tab](http://milanaryal.com/2015/making-external-links-open-in-a-new-browser-tab/#open-link-in-a-new-browser-tab)
* [Open link in a new browser tab using jQuery](http://milanaryal.com/2015/making-external-links-open-in-a-new-browser-tab/#open-link-in-a-new-browser-tab-using-jquery)
* [Target only external links](http://milanaryal.com/2015/making-external-links-open-in-a-new-browser-tab/#target-only-external-links)
* [Add external link indicator](http://milanaryal.com/2015/making-external-links-open-in-a-new-browser-tab/#add-external-link-indicator)
* [Open all links in a new browser tab](http://milanaryal.com/2015/making-external-links-open-in-a-new-browser-tab/#add-external-link-indicator)

## Open link in a new browser tab

We can manually add following atrribute in a anchor tag to open all external links in a new browser tab:
<commit_msg>Post updated<commit_after>---
layout: post
title: "Making external links open in a new browser tab"
date: 2015-02-04T19:25:52+05:45
excerpt: "Learn about best web practices and how to open new links in a new window."
---

Take note that according to most usability experts, opening links in a new browser tab is considered bad practice.

> Avoid spawning multiple browser windows if at all possible -- taking the "Back" button away from users can make their experience so painful that it usually far outweighs whatever benefit you're trying to provide. One common theory in favor of spawning the second window is that it keeps users from leaving your site, but ironically it may have just the opposite effect by preventing them from returning when they want to.
>
> <cite><a href="http://www.snyderconsulting.net/article_7tricks.htm#7">Second browser windows</a>, Seven tricks that Web users don't know</cite>

If you would still like to open external links in a new browser tab/window, follow these instructions.

## Table of contents

* [Open link in a new browser tab](http://milanaryal.com/2015/making-external-links-open-in-a-new-browser-tab/#open-link-in-a-new-browser-tab)
* [Open link in a new browser tab using jQuery](http://milanaryal.com/2015/making-external-links-open-in-a-new-browser-tab/#open-link-in-a-new-browser-tab-using-jquery)
* [Target only external links](http://milanaryal.com/2015/making-external-links-open-in-a-new-browser-tab/#target-only-external-links)
* [Add external link indicator](http://milanaryal.com/2015/making-external-links-open-in-a-new-browser-tab/#add-external-link-indicator)
* [Open all links in a new browser tab](http://milanaryal.com/2015/making-external-links-open-in-a-new-browser-tab/#add-external-link-indicator)

## Open link in a new browser tab

We can manually add following atrribute in a anchor tag to open all external links in a new browser tab:

{'fraction_non_alphanumeric': 0.10405228758169935, 'fraction_numerical': 0.02091503267973856, 'mean_word_length': 4.5050359712230215, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2563239', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1096, 'n_words': 421}