notify('http://cdn.sstatic.net/stackexchange/img/logos/so/so-icon.png','หัวข้อ','รายละเอียด');
function notify(icon,title,body) {
if (!("Notification" in window)) {
alert("This browser does not support desktop notification");
}else if (Notification.permission === "granted") {
var notification = new Notification(title,{
icon: icon,
body: body
});
var i=1;
setTimeout(function () {
notification.close();
}, '10000');
notification.onclick = function () {
notification.close();
}
}else if (Notification.permission !== 'denied') {
Notification.requestPermission(function (permission) {
if(!('permission' in Notification)) {
Notification.permission = permission;
}
if (permission === "granted") {
var notification = new Notification("Hi there!");
}
});
}
}