Answer the question
In order to leave comments, you need to log in
How to track the opening of a tab?
I need to make an ajax request every time I switch to a tab in the browser, i.e. if the user opened the site, then moved to another tab and returned to mine, the request is executed. How to track the moment when the user goes to the tab?
Answer the question
In order to leave comments, you need to log in
https://developer.mozilla.org/en-US/docs/Web/API/D...
works for both tabs and "saved to home screen" pwa-apps so that the data is loaded when the user opens the app again
window.onfocus and window.onblur, if I understood the task correctly. The first event will be executed when the user goes to the tab, the second - when he leaves it
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question