Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/407.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在Chrome中检查鼠标是否位于通知窗口上方?_Javascript_Html_Google Chrome_Google Chrome Extension - Fatal编程技术网

Javascript 如何在Chrome中检查鼠标是否位于通知窗口上方?

Javascript 如何在Chrome中检查鼠标是否位于通知窗口上方?,javascript,html,google-chrome,google-chrome-extension,Javascript,Html,Google Chrome,Google Chrome Extension,仅当用户的鼠标未在显示的通知窗口上方时,我需要在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 ov

仅当用户的鼠标未在显示的通知窗口上方时,我需要在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);

我已经有一段时间没有接触Chrome扩展了,但上次我接触了,你可以使用一个HTML文件作为通知的内容

所以我要做的是:

如果可以在通知中使用JavaScript关闭通知,那么只要使用普通的onmouseover/onmouseout将鼠标是否在通知上存储在布尔值中,并在加载通知后立即从通知中启动超时

如果你不能做同样的事情,但通知交谈的背景页面,使其关闭通知


是的,我知道,但这会使事情复杂化,我宁愿只将文本传递到createNotification中,然后以另一种方式计算鼠标位置。我认为你做不到。除非您可以访问通知的窗口对象。我认为你做不到。@GriefCoder,这是不可能的。您可以尝试打开任务管理器Ctrl+Esc并显示文本通知。您会发现文本通知有自己的独立进程,因此您的扩展无法访问它。似乎您必须使用HTML通知。