Forum Discussion
stop Hyperlink in sharepoint online open new tab
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.
Any suggestions?
- ganeshsanapAug 23, 2023MVP
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.