October 3, 2012

SharePoint: Open Current Navigation links in new window

Challenge

There was a need to open Current Navigation, a.k.a Quick Launch links in new browser window, when being on a front page of a specific section of the SharePoint portal.

Solution

Again, jQuery provides us an easy way to achieve this without having to create custom Navigation controls or providers and whatnot. Please note that this requirement (and solution) assumes that all subsites are visible in Current Navigation. By default, Current Navigation shows two levels of subsites. If there would be more, navigating to third level subsites would not be convenient unless Current Navigation was configured to show at least 3 static levels.

In your master page, add the following JavaScript code:

var isWorkspaces = false;

if(window.location.href.toLowerCase().indexOf('https://myintranet.sharepoint.com/workspaces/sitepages/home.aspx') > -1)
{
    isWorkspaces = true;
}   

// Open left navigation in new window only when in Workspaces section
if (isWorkspaces)
{
    $("#s4-leftpanel-content .ms-quicklaunch-navmgr a").attr("target", "_blank");
}

Technorati Tags: ,

1 comment:

  1. Actually my partners was also fining this solution he were not tried using jQuery,by your suggestion will on that.

    ReplyDelete