Background problem: I have a project like a web base chat application. It contains one page. The JavaScript code is listening to new message from the server through a fetch statement in a setinterval, then displaying on page.
Now, what I need is a way to catch the event that the browser tab is selected or deselected so that I can call setinterval or clearinterval corresponding (to turn my listening on or of).
Thank in advance.
7