visibilitychange event is not triggered when switching program/window with ALT+TAB or clicking in taskbar

前端 未结 4 435
谎友^
谎友^ 2020-12-02 23:15

The problem is with the behaviour of the event \"visibilitychange\".

It\'s triggered: - When I switch to a different tab inside the browser window.

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-02 23:39

    A working solution is proposed described here: https://stackoverflow.com/a/9502074/698168. It uses a combination of the W3C Page Visibility API, blur/focus and mouse movements. Hidden HTML pages related to Alt+Tab are identified in a probabilistic way (i.e. you cannot determine if your page is hidden with 100% accuracy).

提交回复
热议问题