Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Let HTML5 Notification disappear after a delay?

I want to use HTML5 notifications which work great.

The problem is that they never disappear.

How can I set a delay after which the HTML5 notification disappear?

like image 711
confile Avatar asked Mar 14 '23 14:03

confile


1 Answers

You can just call the .close() method:

var n = new Notification("Hello");
setTimeout(n.close.bind(n), 2000);

See here on MDN for details.

like image 137
jfriend00 Avatar answered Mar 21 '23 07:03

jfriend00