Having external links (links that go to other sites, via a http: link) set to open in a new tab often leads to a better user experience. For example, if your Flare topic contains a process, and in that process there is a link to an external site for more information, you don’t really want users to navigate away from the process to get that info – it is better if they can view it in another tab or window. When you add new external links, you can choose for them to target a new tab or new window easily, but what do you do if you have a project with lots of external links and they are all currently set to open in the same tab as your Flare topics? Read on.
Using a Script to Open All External Links in a New Tab
My gut feeling was that maybe a property in the CSS stylesheet could make all external links open in a new tab, but that’s not the case. There are two ways of getting them to open in a new tab:
- Go through the project and reset the target for every external link manually. My God, you don’t want to do this on a large project.
- Use a script on your master page(s). This way is quick and easy, just how I like it.
The script you need to add is as follows (and thanks to Dave Lee for suggesting this on the MadCap Forums):
If you’re not sure about adding the script, you can just copy and paste the following into your master page’s xhmtl code (It can go anywhere inside the body tags. I usually add mine at the bottom).
That’s it! All your external links will open in a new tab, while your internal ones will still open in the current tab (where you are viewing the Flare content).