Maalesef HTML bildirimlerinde bağlantıları ve diğer biçimlendirme için destek yoktur. Bir bildirimle tıklanabilir bağlantı almak için tek yöntem onclick kullanmaktır:
function makeNotification() {
var notification = new Notification('This is a clickable notification', {body: 'Click Me'});
notification.onclick = function() {
window.open("http://stackoverflow.com/");
};
}
function notifyMe() {
// Let's check if the browser supports notifications
if (!("Notification" in window)) {
alert("This browser does not support desktop notification");
}
// Let's check if the user is okay to get some notification
else if (Notification.permission === "granted") {
// If it's okay let's create a notification
makeNotification();
}
// Otherwise, we need to ask the user for permission
// Note, Chrome does not implement the permission static property
// So we have to check for NOT 'denied' instead of 'default'
else if (Notification.permission !== 'denied') {
Notification.requestPermission(function (permission) {
// If the user is okay, let's create a notification
if (permission === "granted") {
makeNotification();
}
});
}
}
Mozilla Firefox Chrome ile karşılaştırıldığında bildirimleri için kısa süreye sahip https://developer.mozilla.org/en-US/docs/Web/API/notification
de ileri belgelerine sahiptir. Firefox'ta bir bildirimin ne kadar süre görünür olduğunu kontrol etmenin bir yolu yoktur.
yılında karşılanması amacıyla Öncelikle teşekkürler. :) Bildirimler iyi çalışır, ancak sadece birkaç saniye, örneğin firefox bildirim gösterisinde ve birkaç saniye sonra otomatik olarak kaybolur, krom bildiriminde kalır ancak onclick birkaç saniye bekledikten sonra çalışmaya devam eder. Nedenini bilmiyorum. – Rob
Evet, ilk başta Chrome’da test ettiğimde farketmedim ama daha sonra cevabımı ilk gönderdikten sonra Firefox’ta test ettim ve aynı şeyi gördüm. Firefox bildirimleri bu şekilde tasarlanmıştır, bu da can sıkıcıdır. Görünüşe göre, Add-On yapmak için SDK kullanıyor olsanız bile, http://stackoverflow.com/questions/20456377/modifying-the-timeout-of-notifications-in-a-firefox-extension ve https değiştirilemez. : //bugzilla.mozilla.org/show_bug.cgi? id = 875114 – JasonCG
Kullanıcı her ne zaman kapatılıncaya dek bildirimi her kapatışınızda yeniden oluşturabilirsiniz: http://stackoverflow.com/questions/25209805/how -do-i-keep-a-bildirim-açık-içinde-firefox – JasonCG