Use this jQuery in your LibGuides Custom JSS/CSS window to add the target attribute of “_blank” to all anchor elements inside LibGuides’ page content boxes which do not already have a target attribute specified.
LibGuides offers a way to set the default behavior for all LibGuides ‘Link’ objects site-wide, such that when clicked they open in a new window or tab. To set this option:
Click Admin (menu) > System Settings (submenu) > General (tab) > Guide Options (accordion) and set Window Target to ‘New Window’.
However, this setting applies only to the LINK content type (the link type added from the ‘Add/Reorder’ dropdown).
The problem is, we most commonly want our LibGuides to persist (stay open) as a launching page, so to say, for all the cool links with which we fill our LibGuides. The setting above does not apply to all the inline links you create in regular paragraphs inside the rich-text editor and you must explicitly change the default target attribute to “New Window (_blank)” for each ‘regular’ link you add to the page.
Thankfully, changing this default is easy with a little jQuery. This can be added to the custom CSS/JS box for an individual guide or the whole site.*
After adding this code, all links which do not already have their target attribute set will be set to
target="_blank" and open in a new window or tab automatically. If you now wish to have a link load in the same window, you will need to set this manually. You can do this in two ways.