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."
the a.ms-draggable was key to this so it didn't interfere with other links on the page.
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.
- I put a script editor web part on the page
- I downloaded the JQuery into the Site Assets app
- 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>
Comments