0

Ensure URL is opened only once! I am currently programming a little program which opens an URL in the default browser every time I click a button. So with every click a new TAB is opened in the browser. So my question is: Is there any way to determine if the URL is already opened and if so only switch to this TAB and don't open a new TAB?

talex
  • 17,973
  • 3
  • 29
  • 66
  • You have to use javascript for that purpose, Loop through every opened tab in browser and check the url, Reference: https://stackoverflow.com/questions/11915370/retrieving-which-tabs-are-open-in-chrome – Hammad Sajid May 07 '19 at 06:06
  • @HammadSajid you link is applicable if you create chrome extension. Won't work in site javascript. – talex May 07 '19 at 06:09
  • you can use LocalStorage and it can be used via all browsers, it is not browser dependent. Reference: https://www.codediesel.com/javascript/sharing-messages-and-data-across-windows-using-localstorage/ – Hammad Sajid May 07 '19 at 06:13
  • @HammadSajid how locals storage helps in this situation? – talex May 07 '19 at 06:26

2 Answers2

0

It is impossible without creating browser extension.

talex
  • 17,973
  • 3
  • 29
  • 66
0

Try the target attribute of a element, or the second parameter of window.open()

You can use them to make the browser always open the URL in the named window you defined while user click on the button or hyperlink And use session to control the content within the opened window

Please know that this can NOT really restrict the user to "open the URL" manually (copy paste, add bookmark, etc.)

The restriction will still need to be implement with session controlling in the URL you're working

Mech Tsai
  • 190
  • 6