Open Links App in new tab using JQuery

I needed to edit a SharePoint 2013 page to open links from a Links app webpart in a new tab as the links were used for reference for the form on the page. Users were clicking the links and losing their progress in the form fields. We weren't able to reliably explain "right-click to open in new tab."

I found a SharePoint designer solution which explained modifying the XSLT. I didn't want to attempt it. JQuery should be able to do this for you. 

  1. I put a script editor web part on the page
  2. I downloaded the JQuery into the Site Assets app
  3. I put the following snippet into the script editor webpart


<script type="text/javascript" src="/sites/sitename/SiteAssets/scripts/jquery-3.4.1.min.js"> </script>
<script>
$(document).ready(function(){

  $('a.ms-draggable').click(function(){
    window.open(this.href);
    return false;
  });

});

</script>

the a.ms-draggable was key to this so it didn't interfere with other links on the page.

Comments

Popular posts from this blog

Robocopy Error 31 A device attached to the system is not functioning

"The following factors also affect the level of access for" user with excess permissions

Unknown server tag 'AdminControls:MigrationToolPromotionTip'. in Central Admin after installing SharePoint 2013 security update KB4482464