stop Hyperlink in sharepoint online open new tab

Copper Contributor

Hello!

I have a picture with hyperlinks in sharpont online, but i want to stay in the same tab when klicking.

It opens a new tab, and it will be som many tabs thats confusing, is there i solution for this to stay in the same tab?

 

 

 

5 Replies
SharePoint will automatically open in a new tab if the URL to the item isn't using your tenant's SharePoint URL. I had the opposite issue, where I wanted to open links in a new tab rather than the current tab. I used some Javascript and the Modern Script Editor to make that work.

https://steveknutson.blog/2023/05/20/sharepoint-quick-links-open-in-new-tab/

You could do the opposite with a small modification to the code I used. Change the a.target="_blank"; to a.target="" and change the startsWith URL.

I hope that helps.
I installed modern scriprt app and changed the code but i did not work for me. Hyperlinks in dokument still opens in new tabs. I am no expert at java, but i paste the exatly code.
Seems like hyperlinks always opens a new tab, still the link is in the tenant.

@william41550 Try _self instead of _target: 

 

a.target="_self";

 


Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

It does not work, still opens a new tab when i click on hyperlinks in a ppt , the links are in the same tenant. if i do a quicklink it opens in the same tab , but not hyperlinks in a dokument.
Any suggestions?

@william41550 That is a default behavior in SharePoint to open the hyperlinks inside the document/PPT content in new tabs.

 

Unfortunately, you cannot override this behavior even with the modern script editor and HTML/CSS/JS.

 

Above code and modern script editor will only work for the anchor tags (<a>) / hyperlinks which are directly available in the DOM structure of a SharePoint page - like for links in quick links web part, site navigation links, links in text web part, etc.


Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.