Check background or foreground status of web app

I'd like to check weather my web application is running in background or foreground, You can check it very easily in JavaScript. hasFocus() is the function which tells that your window is active or not.

Here in below example I have create checkForeGroundBackGround() function and inside the body of it we check the window status.

We call back checkForeGroundBackGround() function periodically to check the status.

window.document.hasFocus()¬†returns the web app status true if app is in foreground and false if app is in background. ...  Read More

Share This: