如何知道是什么引起了能见度的变化

I am using visibilitychange event of the browser. The website is for mobiles. So I test it from my mobile.

document.addEventListener('visibilitychange', (e) => {
    console.log("visibility changed", e);
})

这可能是由许多不同的原因引起的。

  • 来回切换应用程序
  • 强制关闭应用
  • 屏幕关闭时

Is there any way to detect what behaviour caused visibilitychange listener to get called? I tried e.target and e.srcElement, but in all cases, they seem to be the same. Any ideas?

评论