JS multi-page prompt function at the same time how to write?

as shown in the picture, the structure of the browser is: 1 br 2 strong 3 is a business web page, while a yellow web page is an irrelevant web page.
page 1 Magi 2 Magin3 is a business web page, which needs to add a prompt function. three minutes poll the background once, and if there is no, everything is still. It requires three pages to produce prompt tone and prompt text "at the same time".

  1. if three pages exist on the browser at the same time, which web page the current user is browsing, the current web page will have a tone and text, while other pages will only have text
  2. if three pages exist on the browser at the same time and the user is browsing other unrelated pages (all three pages are not active), only page 2 will generate a tone and other pages will have prompt text
  3. the order in which the user opens the page is random and unordered, but requires three pages to be prompted at the same time and can only have

4. If you open only one web page, it"s easy to say that you can check the background once in three minutes, but if you open two or three pages at the same time, there will be the above three problems.
I think when opening the first page, everything will be all right. If the user jumps from the first page to the second page and passes a time parameter, this ensures that the page in the browser will request the interface at the same time, but there may be errors due to problems such as browser, server and network speed. I don"t know what to do, and the manager is not allowed to use websocket.
I would like to ask if you have any good ideas?

Dec.27,2021

use localStorage to share the status
indicates whether there is a page processing
b indicates whether there is a prompt
each page to start a timer, each time to read the corresponding status, and do corresponding processing
when each page is lost in the current window, Also write the corresponding state


you can use sharedworker in webworker to realize that multiple pages share an extra thread of a browser in this thread and distribute it uniformly to other pages

.
Menu