Chrome扩展程序开发:自动关闭通知框

Rya*_*yan 7 notifications google-chrome auto-close

做完之后我运行这段代码:

var notification = webkitNotifications.createNotification(
   'icon.png',  // icon url - can be relative
  'Done!',  // notification title
  'Just updated your list!'  // notification body text
   );
  notification.show();
Run Code Online (Sandbox Code Playgroud)

这当然会在用户屏幕中弹出通知.

无论如何它在那里通知这个通知,以便它在X秒内自动关闭?

谢谢![R

小智 16

您可以使用 notification.cancel();


小智 9

var notification = webkitNotifications.createNotification('images/icon-48x48.png',"This is       Title","Biswarup Adhikari Notification");
notification.show();
setTimeout(function(){
notification.cancel();
},2000);
Run Code Online (Sandbox Code Playgroud)

Chrome通知将在2000毫秒或2秒后自动关闭.