2016-12-01 45 views

回答

1

Chrome有一個專用API chrome.idle來檢測閒置狀態。

chrome.idle.queryState(
    5 * 60, // seconds 
    function(state) { 
    if (state === "active") { 
     // Computer not locked, user active in the last 5 minutes 
    } else { 
     // Computer is locked, or the user was inactive for 5 minutes 
    } 
    } 
); 

它還提供了一個事件,chrome.idle.onStateChanged,通知您的狀態變化時。如果您想知道用戶是否在瀏覽器窗口中處於非活動狀態,您可以看到這篇文章 - Is there a way to detect if a browser window is not currently active?

+0

謝謝。我正在chrome.tabs中尋找它。 – SKG

相關問題