0

I am working on a project and I want to incorporate a feature where a user should not able to open a new tab just like in many exams we give online we can't open a new tab same feature I want to implement using Spring boot and Angular. I am new in this please help me out.

  • 1
    The user should not be able to open your Angular website in another tab or open any site at all in another tab? – D M Jul 30 '21 at 14:36
  • Also, what have you tried and where are you getting stuck? – D M Jul 30 '21 at 14:37
  • I have tried to search a lot but I dont have much idea how to implement please can you give some direction I have checked to disable right click but it wont help I need to prevent opening a new tab in same browser as well as I want prevent it to open the same link in any browser – Rahul Singh Jul 30 '21 at 14:40
  • you want to prevent the ctrl+click or mouse wheel click? (Both actions opens a new tab in windows) – Hoch Jul 30 '21 at 14:43
  • Why would you want to do that? I don't think there is any - non hacky / if any - way to achieve this and also I currently can not think of any reason why to do that in a web application. – Fussel Jul 30 '21 at 14:50

1 Answers1

0
  1. You can leverage localStorage to check if there're other tabs already opened. check here

  2. Use the Service Worker to get a list of clients (tabs) that are currently opened (https://developer.mozilla.org/en-US/docs/Web/API/Clients).

https://web.whatsapp.com/ is an example of what you want.

Ezzabuzaid
  • 529
  • 1
  • 5
  • 13