Answers.Body: <p>In Craft 3, you can set <code>"linkNewtab": true</code> and <code>"linkTarget": "_blank"</code> in your redactor config. This should default so the "Open in new tab" is automatically checked when creating links in a redactor field.</p>
  
  <p><a href="https://imperavi.com/redactor/docs/settings/link/" rel="nofollow noreferrer">https://imperavi.com/redactor/docs/settings/link/</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-24T01:45:50.407Z
Answers.Text: (Quibbling, but this of course only affects content in Redactor fields.  It does not result in _all_ external links opening in a new windows - which, again, may or may not be desirable, but the JS solution below is more general, if you do want this...)
Answers.UserDisplayName: Jeremy Daalder
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-16T15:28:58.593Z
Answers.LastActivityDate: 2020-04-16T15:28:58.593Z
Answers.UserDisplayName: Jeff Irwin
Answers.Body: <p>Merits of doing this aside, I agree that JS is probably the easiest way to go here.</p>
  
  <p>This code adds <code>target="_blank"</code> to all external links. </p>
  
  <pre><code>// Make sure any offsite links (non js/mailtos) open in a new window
  // from https://css-tricks.com/snippets/jquery/open-external-links-in-new-window/ - comment at end.
  function openAllExternalLinksInANewWindow() {
      $(document).on('mousedown', 'a:not([href*="mailto:"],[href*="javascript"])', function(e) {
          var isInternalLink = new RegExp('/' + window.location.host + '/');
          if (!isInternalLink.test(this.href)) {
              $(this).attr('target', '_blank');
          }
      });
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-29T05:52:07.230Z
Answers.Text: The only case in which I'd use target="_blank" is if opening a link would destroy some content the user has made on your site. In all other cases it's a very bad practise.
Answers.UserDisplayName: KnutSv
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-30T08:42:03.927Z
Answers.Text: Thanks Jeremy. I should've explained better in my question that yes I just wanted to add it just to external links. I'm surprised to see @KnutSv opposed to adding target="_blank". Could someone maybe point me to a discussion or study on the pros and cons of using it? Maybe I'm just naive on this one.
Answers.UserDisplayName: patrick.altair
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-30T23:46:23.767Z
Answers.Text: That's almost a holy war on the web :)  Persoanlly, I don't mind it for external links as we have a large, complex site, and people don't like losing their place on it...but I can also understand others views that it's always bad practise...
  
  I'll edit my answer above to reflect the updated question.
Answers.UserDisplayName: Jeremy Daalder
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-31T07:34:04.077Z
Answers.Text: @patrick.altair People like to control for themselves whether a link should open in a new tab. I always hate when a site forces me to open external links in new tabs, just imagine if Google forced you to open all external links in new tabs. It's the same with your site, maybe they're just passing through? https://straightupcraft.com/craft-plugins/ does this when you go to the plugin page and it's always a pain in the ass to have to go back and close the original tab. Also less experienced users and blind users don't notice the new tab, just that they can no longer use the back button
Answers.UserDisplayName: KnutSv
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-31T11:48:43.857Z
Answers.Text: Ah ok, I can see both sides now. In my case its longform articles that link to products talked about in the articles. I wanted to open this is a new tab so readers don't lose their place in the article basically but this has made me reconsider. Thanks for the discussion guys!
Answers.UserDisplayName: patrick.altair
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-29T00:19:31.517Z
Answers.LastActivityDate: 2016-08-30T23:47:13.430Z
Answers.LastEditDate: 2016-08-30T23:47:13.430Z
Answers.UserDisplayName: Jeremy Daalder
Answers.Body: <p>I've been trying to gather ideas from different places and still not sure how can I do it on Craft 2 having Redactor v2.13 or Redactor II. I looked into the redactor.js file (it's a huge file about 10k lines) and didn't find <code>linkTarget: '_blank'</code> to <code>linkTarget: '_blank'</code> May be it's because of difference in versions? There are similar mentions though such as</p>
  <p><a href="https://i.sstatic.net/ilEr0.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ilEr0.png" alt="Link Target settings Redactor 2.13" /></a></p>
  <p><a href="https://i.sstatic.net/nLq3D.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/nLq3D.png" alt="linkNewTab settings" /></a></p>
  <p>I'd try to explore more and see how this goes. Just incase if someone has already gone through this.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-01T13:22:47.800Z
Answers.LastActivityDate: 2021-06-01T13:22:47.800Z
Answers.UserDisplayName: Anvar Jamal
Body: <p>I have a website where by default I would like all external links to have the "open in a new tab" option to be selected by default. I'm wondering if this is possible either through craft or redactor? I came across <a href="https://github.com/fruitstudios/LinkIt" rel="nofollow">this</a> but think it may be overkill so I'm wondering if its possible without a plugin. </p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-08-28T22:25:30.653Z
Comments.Text: Guessing the easiest solution would be to add target="_blank" to all link elements with javascript. But the UX of doing this is awful. There is hardly any cases where target="_blank" is a good idea.
Comments.UserDisplayName: KnutSv
Tags: <redactor><link>
Title: Is it possible to make links open in a new tab by default?
ThreadText: # Is it possible to make links open in a new tab by default?
  
  (Asked by: username_0 on 2016-08-28)
  
  I have a website where by default I would like all external links to have the "open in a new tab" option to be selected by default. I'm wondering if this is possible either through craft or redactor? I came across [this](https://github.com/fruitstudios/LinkIt) but think it may be overkill so I'm wondering if its possible without a plugin.
  
  **Tags:** redactor, link
  
  > **Comments:**
  > **username_1**: Guessing the easiest solution would be to add target="_blank" to all link elements with javascript. But the UX of doing this is awful. There is hardly any cases where target="_blank" is a good idea.  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_2 on 2020-04-16. Score: 2 | Accepted answer
  
  In Craft 3, you can set `"linkNewtab": true` and `"linkTarget": "_blank"` in your redactor config. This should default so the "Open in new tab" is automatically checked when creating links in a redactor field.
  
  <https://imperavi.com/redactor/docs/settings/link/>
  
  > **Comments:**
  > **username_3**: (Quibbling, but this of course only affects content in Redactor fields.  It does not result in _all_ external links opening in a new windows - which, again, may or may not be desirable, but the JS solution below is more general, if you do want this...)  
  
  ---
  
  ### Answer by username_3 on 2016-08-29. Score: 6
  
  Merits of doing this aside, I agree that JS is probably the easiest way to go here.
  
  This code adds `target="_blank"` to all external links.
  
  ```
  // Make sure any offsite links (non js/mailtos) open in a new window
  // from https://css-tricks.com/snippets/jquery/open-external-links-in-new-window/ - comment at end.
  function openAllExternalLinksInANewWindow() {
      $(document).on('mousedown', 'a:not([href*="mailto:"],[href*="javascript"])', function(e) {
          var isInternalLink = new RegExp('/' + window.location.host + '/');
          if (!isInternalLink.test(this.href)) {
              $(this).attr('target', '_blank');
          }
      });
  }
  
  ```
  
  > **Comments:**
  > **username_1**: The only case in which I'd use target="_blank" is if opening a link would destroy some content the user has made on your site. In all other cases it's a very bad practise.  
  > **username_0**: Thanks username_3. I should've explained better in my question that yes I just wanted to add it just to external links. I'm surprised to see @username_1 opposed to adding target="_blank". Could someone maybe point me to a discussion or study on the pros and cons of using it? Maybe I'm just naive on this one.  
  > **username_3**: That's almost a holy war on the web :)  Persoanlly, I don't mind it for external links as we have a large, complex site, and people don't like losing their place on it...but I can also understand others views that it's always bad practise...  I'll edit my answer above to reflect the updated question.  
  > **username_1**: @username_0 People like to control for themselves whether a link should open in a new tab. I always hate when a site forces me to open external links in new tabs, just imagine if Google forced you to open all external links in new tabs. It's the same with your site, maybe they're just passing through? https://straightupcraft.com/craft-plugins/ does this when you go to the plugin page and it's always a pain in the ass to have to go back and close the original tab. Also less experienced users and blind users don't notice the new tab, just that they can no longer use the back button  
  > **username_0**: Ah ok, I can see both sides now. In my case its longform articles that link to products talked about in the articles. I wanted to open this is a new tab so readers don't lose their place in the article basically but this has made me reconsider. Thanks for the discussion guys!  
  
  ---
  
  ### Answer by username_4 on 2021-06-01. Score: 0
  
  I've been trying to gather ideas from different places and still not sure how can I do it on Craft 2 having Redactor v2.13 or Redactor II. I looked into the redactor.js file (it's a huge file about 10k lines) and didn't find `linkTarget: '_blank'` to `linkTarget: '_blank'` May be it's because of difference in versions? There are similar mentions though such as
  
  [![Link Target settings Redactor 2.13](https://i.sstatic.net/ilEr0.png)](https://i.sstatic.net/ilEr0.png)
  
  [![linkNewTab settings](https://i.sstatic.net/nLq3D.png)](https://i.sstatic.net/nLq3D.png)
  
  I'd try to explore more and see how this goes. Just incase if someone has already gone through this.
  
  
  ---
  
  