We are using O365/Sharepoint Online 2013.
In our intranet we have the OOTB Links List on a page so users can add links to important external websites in it. As a default those links are just opening in the current window and effectively taking the user out of the intranet site.
We would like to have the links open in a new tab when clicking with the left mouse button. How can this be done? I thought of making a .js Javascript file and link it using the Link List's "JS-Link" option in the toolbox but as I don't know any Javascript I can't write it myself.
I have searched the internet high and low, tried different scripts and solutions but just can't seem to get it working right. Feels like this kind of this should be a default option in Sharepoint.
** EDIT/SOLUTION **
I managed to figure it out right after I made this question. I have one script that didn't work in my .js file and I just blindly edited it to try one more desperate thing and it worked!
So if anyone else wants to know, the answer is to make a filenamehere.js and include the following script inside it:
$(document).ready(function() {
$("a").removeAttr('onclick').attr("target","_blank");
});
After that, save the script file in your Site Collection SiteAssets folder and put "~sitecollection/SiteAssets/filenamehere.js" in your JS-Link option in the Web Part settings/toolbox. :-)
EDIT 2: I noticed that somehow the script is now applied to the global site navigation links too even when I have applied the script on in the Web Part JS-Link option. If anyone knows how to fix this, that would be more than awesome! :-)