js 监听窗口是否被激活

document.addEventListener("visibilitychange", function() {
  console.log( document.hidden );
  // Modify behavior...
});

文档链接:

https://developer.mozilla.org/en-US/docs/Web/API/Document/hidden

 
posted @ 2021-01-28 10:24  秃头的铲屎官  Views(486)  Comments(0Edit  收藏  举报