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 but think it may be overkill so I'm wondering if its possible without a plugin.
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.
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.
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
I'd try to explore more and see how this goes. Just incase if someone has already gone through this.