1
http://developer.chrome.com/extensions/notifications.html如何檢查鼠標是否在Chrome的通知窗口?
我需要關閉X秒後通知窗口只有當用戶的鼠標不超過所顯示的通知窗口。
var notification = webkitNotifications.createNotification(
'icon.png',
'Notification titile',
'Notification body text'
);
notification.show();
// TODO: Close notification window only if user's mouse is not over it
setTimeout(function() { notification.cancel() }, 10000);
是的,我知道,但這使事情複雜化,我寧願將文本傳入createNotification(),並找出相反的鼠標位置 –
好吧。我認爲你不能這樣做。除非您可以訪問通知的窗口對象。我認爲你不可以。 – xavierm02
@GriefCoder這是不可能的。您可以嘗試打開任務管理器(Ctrl + Esc)並顯示文本通知。你會發現文本通知有其獨立的過程,所以你的擴展無法訪問它。看起來你必須使用HTML通知。 –