Wednesday, 15 February 2017

how to Open Quick Launch link In New Tab for SharePoint using code

This article will you how to Open Quick Launch link In New Tab for SharePoint, commonly I got this question from many of developers about new tab opening by clicking on link available in quick launch page.
The Quick Launch contains links to select the settings, lists and libraries of the current site or site collection which contents as above. Also page can optionally contain links to subsites and pages of the current site. We use the Quick Launch to navigate between different areas of your site and to access immediate like favourite button.
Below are the steps to open quick launch link in new tab for SharePoint online publishing site.
To do the testing open publishing site in Google chrome or any other browser with you are compatible.
Press F12 and click on pick an element of the page and move to the main logo page of SharePoint.
Once you clicked on the like below, now copy the document element name for using in the below code
Now we can paste SharePoint element and paste to highlighted path:
Note: Default left navigation element name will be same like below.
var a =  document.getElementById('ctl00_PlaceHolderLeftNavBar_QuickLaunchNavigationManager').getElementsByTagName('a');
for (var i = 0; i < a.length; i++) {

    var elem = a[i];
console.log(elem.text);
     elem.target = "_blank";
   
}
Once done do test by clicking any of navigation link and verified opening in new tab.
So now we will be update the same to Master Page Of SharePoint site using SP designer.
Below are the steps to configure the same in Master page:
  • Open SPD and connect the site with authorised user account and password.
  • Navigate page to master page and open seattle master page and copy the above code and paste here same as below screen shot:
  • Once done above, save this file and verified it’s working fine.

Thanks

No comments:

Post a Comment