Event for browser tab hidden/shown?

前端 未结 3 772
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-06 08:26

Is there any DOM event for when the browser tab loses/gains focus? I know there are the blur and focus events on window, but they also

3条回答
  •  余生分开走
    2021-01-06 09:16

    At least Google Chrome supports a webkitvisibilitychange event and a document.webkitHidden property. See the visibility API. But it seems only to fire when the shown tab changes, not when the whole window is minimized. There also seems to be a visibilitychange event for Internet Explorer, but the documentation doesn't say anything about it.

提交回复
热议问题