Hello everyone, I am in search of a Javascript event that can detect when a mobile browser window regains focus. This could happen when a user closes or minimizes their browser to switch back to the home screen or another app, or when the device resumes from sleep mode due to user powering it off or screen timeout.
I would prefer to find a single event that works universally, but I understand that might be difficult! The 'pageshow' event seems to work for iOS devices, but is not very reliable for everything else. I have tried using 'focus' and 'DOMActivate', but they do not produce the desired outcome.
It's important to note that the page may not always contain form elements, and I want the event to trigger without requiring the user to interact with the page again.
This need for such an event arises from our code regularly checking for new content through XHR requests. These requests are not made while the browser is asleep, leading to issues with receiving updated content and restarting timeouts.
Thank you in advance for any assistance you can offer!