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.


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() {

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! :-)

  • Where can I get the WebPartWPQ Number following for the List that I need it? A List/LIbrary has no WebPart Setting to point to the Javascript? Help please. Commented Mar 23, 2016 at 11:36
  • Using browser's developer tools (F12) you can inspect any elements and their tags/attributes. Also I'm not being mean but you should not use answers to ask another question. Better way is to use the comments or preferably ask/create a new question. :-)
    – Tenttu
    Commented Mar 23, 2016 at 11:39

2 Answers 2


I managed to solve the problem and just wanted to share the answer with anyone who might be searching for the same thing. So I just studied jQuery a bit to see how it works and the solution was simple, just needed to make a more specified target for the script rather than just a which selects all links.

What I did was select all links in the specified List (WPQ#). Here's an example if your list is named "WebPartWPQ1":

$(document).ready(function() {
$( "#WebPartWPQ1 a" ).attr("target","_blank");

I hope this helps anyone who has the same need to open Links List items in a new tab! :-)


you'll have to add the $("#WebPart...") line for each webpart you want you to take effect if you want to leave the top nav bar links alone.

Not the answer you're looking for? Browse other questions tagged or ask your own question.