question

JimmyDetts-6992 avatar image
0 Votes"
JimmyDetts-6992 asked JerryXu-MSFT commented

How to stop a new tab opening in SharePoint

I have a file inserted into a SharePoint page using File Viewer, this file, a PDF, has some links to other pages within the site. When you follow these links the page opens up in a new tab rather than the same one. How can I keep the page from doing that as it isn't the best when you have all these new tabs opening.

office-sharepoint-online
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JerryXu-MSFT avatar image
0 Votes"
JerryXu-MSFT answered

Hi, @JimmyDetts-6992 ,

Per my knowledge, we cannot control the open behavior or a file viewer web part out of box in a modern page. It is by-design. Here is a User Voice talking about similar idea, you can vote there and wait for Microsoft to provide a solution or workaround.


If an Answer is helpful, please click "Accept Answer" and upvote it.
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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JimmyDetts-6992 avatar image
0 Votes"
JimmyDetts-6992 answered JerryXu-MSFT commented

That is strange and I would have thought there would be a simple HTML coding solution to this. After all the weblink from the web part goes to the same SharePoint site but opens in a new tab.

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi, @JimmyDetts-6992 ,

For classic experience, you can try to add a script editor web part to insert HTML codes to do so. And for modern experience, it is not allowed out-of-box to directly insert code for customization. Especially for your scenario we are handling link inside a File viewer web part. There are 3rd party tools like modern script editor which enables you to insert codes. However we are not able to provide more help on custom solutions.

While Microsoft supports and encourages open-source software development, it does not provide technical support for the softwares from third parties, nor does it guarantee that the software will work as described.


0 Votes 0 ·

Someone has posted the following:
Barry commented · March 17, 2021
I've struggled with this for ages but have found a relatively simple solution to stop internal links opening in a new tab.

Instead of the full page link -

http://companyname.sharepoint.com/sites/wwt_projects_cs.aspx

just use the last part of the link -

/sites/wwt_projects_cs.aspx


However when I try this and upload the image with the URL in the same format as below the url is not recognised.

0 Votes 0 ·

Hi, @JimmyDetts-6992 ,

I tested with it and it did not get recognized as a link either. It may only work for direct links. You can open a service request about this feature if your really need it.


0 Votes 0 ·