What should be done when a user navigates to a neighboring previously open tab with a site, information on which may already be outdated (for example, no data entered, any settings, previous language, etc.):

  1. Reload page right in front of the user's nose (catching the window.onfocus tab activation event).
  2. Show the user the blank page "Refresh page".
  3. Nothing to do.
  • one
    4. Load new data in the background via ajax :) - andreymal
  • Although I personally tend to point 3: I can easily leave the tabs open just to keep the old data there - andreymal

3 answers 3

If it is important to maintain the relevance of one entity or several but related (for example, if you have one table and several people can edit it), then option 2.

3 option - if the user himself changes the data and remembers it.

Option 1 - in general, this should never be done.

  • And I just chose the first option. - user208916
  • Well, I agree that the decision is not elegant, but simple and reliable. - user208916 pm
  • Cheto I thought and still agree - the reboot infuriates before the nose. - user208916
  • It may happen that there will be changes on both tabs, then you will lose one of them. - Aleksander K.

there are 2 automation options 1 use localStorage / sessionStorage + listener 2 use websocket to send data to the inactive tab

    In general, the best option for the user is to synchronize open tabs via localStorage, see the Storage Event . It is noteworthy that this method is offline-first .

    • I just use the onstorage event to assign for other tabs the windows.onfocus event handler to reboot. Before that, I tried to update other tabs in the background of the onstorage event, but this didn’t lead to anything good: difficult, a lot of bugs, even a brake in IE. - user208916
    • Why preload the page? You can transfer anything through localStorage and refresh the tab without reloading the page. - Vadim
    • but the most optimal use is websocket. If you need to use old browsers, there is emulation on the flash. when using websocket, it makes no sense to update the pages; you can simply update the necessary data. moreover, the data can be updated on the tab, even if they were changed by another user, thus the data will always be relevant. and if (for example) only one cell in the tamblice has been updated, there is no sense in updating the entire table, it is enough to update only this cell. - Vadim
    • Vadim, you choose the wrong tool. Web sockets are designed to provide fast transfer of frequently changing data (several times per second), where it is expensive to constantly reconnect and send extra data. The tool is best suited for gaming, stock data and, for example, chat (and even then with a stretch). but not for forms. - Aleksander K.