Detect change of browser tabs with javascript

此生再无相见时 提交于 2019-12-05 07:51:17

Trap the window.onblur event.

It's raised whenever the current window (or tab) loses focus.

Most probably there is no standards javascript for this. Some browsers might support it but normally there is only a window.onblur event to find out the user has gone away from the current window.

The Page Visibility API was designed to do this. Have a read at this URL:

https://developer.mozilla.org/en-US/docs/Web/Guide/User_experience/Using_the_Page_Visibility_API

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!