Ondexx has the ability to add Custom Scripts to your Sites. These scripts can serve many different purposes – you can view these under Administration > Site Setting > Custom Scripting. This menu is accessible by users with the “Configure Site” right.
The below script will cause all hyperlinks in your Site to open in a new window by default. This will exclude any in-page links as well. To add this script to your site:
- Copy the code below to your clipboard.
- Navigate to Administration > Site Settings > Custom Scripting.
- Paste the code below in the “Page Header Scripting” section. If there are already scripts in this field, leave them intact, and paste the code below.
- Click SAVE to add the script to your site. All hyperlinks will now open in a new tab by default.
/* FORCE LINKS TO OPEN IN A NEW WINDOW (excludes in-page links) */
$(document).ready(function() {
/* step 1: clean-up */
$('.component-content a[href=""]').each(function(i) {
$(this).removeAttr('href');
});
/* step 2: add target attribute */
$('.component-content a:not([target]):not([name]):not([id]):not(.anchorjs-link):not([href*="#"]):not([class*="lazyload"]):not(.btnViewDoc):not(#btnDownloadDoc):not(.btnLocateFile)').each(function(i) {
$(this).attr('target', '_blank');
});
});