Aug 15 2023 06:31 AM
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?
Aug 19 2023 02:25 PM
Aug 21 2023 11:59 PM
Aug 22 2023 04:22 AM
@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.
Aug 23 2023 05:07 AM
Aug 23 2023 05:14 AM
@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.