1

I'm trying to make two links on the left navigation open up into a new tab as they are external sites. It should be as easy as adding target="_blank" to their HTML element but when I wrote some jQuery to do this task the target gets added to the href of the link but it doesn't do anything to change the functionality.

Currently I have this code:

<script type="text/javascript">
_spBodyOnLoadFunctionNames.push('openNewTab');
function openNewTab() { 
jQuery('a[href$="?newTab"]').attr('target', '_blank'); 
};</script>

_spBodyOnLoadFunctionNames.push('openNewTab') is the SP equivalent of document.ready and it calls up my function openNewTab. jQuery is used instead of the usual $ to be sure that it doesn't mess with SP. Found this info here

This code works on any link that I add ?newTab to within my page and they open in new tabs. However, it still does NOT work on links found in the navigation on the left of the page. Though it does add the target="_blank" when inspected it displays as:

<a class="static menu-item ms-core-listMenu-item ms-displayInline ms-navedit-linkNode" tabindex="0" href="http://itgenwebapps.comp.dirsrv.com:8080/EnergyAppGUI/index.html?newTab" target="_blank"><span class="additional-background ms-navedit-flyoutArrow"><span class="menu-item-text">Fleet Dashboard</span></span></a>

Is there some out of the box solution to making these links go to a tab on a link to link basis? If there is or if someone has found how to make select links open in a new tab either would be much appreciated information.

1 Answer 1

6

Go to Site setting --> Under look and feel go to Navigation

Select the link which you want to open in new tab , and edit that link

Check open in new tab and its done.

CHeck the box

Hope this helps

5
  • I honestly hadn't even seen that part before - I've just been editing that navigation with "EDIT LINKS" so it's good to know this exists. However, I checked the box and I have the appropriate link and everything and it doesn't actually open in a new window still.
    – calebben3
    Aug 5, 2015 at 15:22
  • 2
    You have to deactivate Minimal Download Strategy feature in order to work this functionality. Aug 5, 2015 at 15:28
  • 1
    Site Setting --> Under Site Action --> Manage Site Feature --> There you will find Minimal Download Strategy feature . Deactivate it. Aug 5, 2015 at 15:52
  • Thanks! I googled that last bit about 10 seconds before I saw your comment. It works as desired now. :D To think it was so simple and OOB when I was working on it for hours.
    – calebben3
    Aug 5, 2015 at 15:54
  • Great !! This happens a lot with me as well :) Aug 5, 2015 at 15:55

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