In the Hub navigation, how to open a link in a new window?

frob 4,261 Reputation points
2022-02-10T21:48:23.307+00:00

Hi there

In a SharePoint Online site, in the Hub navigation, how to open a link in a new window?

Thanks.

Microsoft 365 and Office | SharePoint | For business | Windows
0 comments No comments
{count} votes

Accepted answer
  1. Allen Xu_MSFT 13,866 Reputation points
    2022-02-11T03:14:37.853+00:00

    Hi @frob ,

    Inject below JS code to the page:

    <script language="JavaScript">  
    var a = document.getElementByClassName("<classname>")  
    a.setAttribute("target",'_blank');  
    </script>  
    

    ALTERNATIVE WAYS: right click the link and select "Open link in new tab" or hold down the CTRL key before clicking the link in a browser, the link opens in a new tab.

    ----------

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


1 additional answer

Sort by: Most helpful
  1. Ganesh Sanap 211 Reputation points
    2022-09-05T06:10:00.68+00:00

    @frob Microsoft is releasing a new feature using which you can configure navigation links to open in a new browser tab - in SharePoint online modern experience.

    So, now you don't need to inject custom JavaScript or CSS (which is not recommended by Microsoft).

    Follow this article for more information & feature release timeline: SharePoint: Configure Navigation Links to Open in a New Tab

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.