[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