kangduu / front-end-camps

Front-end learning, interviews, question banks, algorithm camps.
https://kangduu.github.io/front-end-camps
MIT License
2 stars 0 forks source link

Q:如何确定页面的浏览器选项卡是否聚焦? #18

Open kangduu opened 1 year ago

kangduu commented 1 year ago

const isBrowserTabFocused = () => !document.hidden;

// 示例 isBrowserTabFocused(); // true