[HTML5] document.hidden


特殊说明:

通过document.hidden属性,可判断页面是否可见。 如果不可见,则document.hidden为true. 如果可见, 则为false。

但是, 如果该页面只是被其它窗口挡住, 而非最小化该页面。 则document.hidden仍然是false. 而不是不可见。

Example:

//startSimulation and pauseSimulation defined elsewhere
function handleVisibilityChange() {
  if (document.hidden) {
    pauseSimulation();
  } else  {
    startSimulation();
  }
}

document.addEventListener("visibilitychange", handleVisibilityChange, false);

 

see:

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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM