Reputation:
i read this question and this is very useful for me. Chrome desktop notification example? is there any way to customize Notification via HTML markup?? and custom CSS styling for that Notification
var notification = new Notification('Notification title', {
icon: 'http://cdn.sstatic.net/stackexchange/img/logos/so/so-icon.png',
body: "<h2>Hey there! You've been notified!</h2>"+
"<span>this is another element</span>",
});
UPDATE : one more thing as notification body blow show web address how can hide that web address if i want to
Upvotes: 4
Views: 3854
Reputation: 1019
According to Notification API , you can't use HTML markup.. but you can use newline, tab,bold ,....)
if (!("Notification" in window)) {
alert("This browser does not support system notifications");
}
// Let's check whether notification permissions have already been granted
else if (Notification.permission === "granted") {
// If it's okay let's create a notification
var notification = new Notification("<h1>Hi there!</h1>");
console.log(notification);
}
Upvotes: 0
Reputation: 103
You cannot use HTML in the body of the message. But you can use unicode markup in alert body for instance (such as newline, tab and so forth).
Upvotes: 1
Reputation: 446
Using HTML in desktop notification is not allowed, you can only add an onclick handler for the notification as follows:
function raiseNotification() {
var notification = new Notification('Notification subject', {body: 'You can click on notification'});
notification.onclick = function () {
alert('Hi there!');
};
}
Upvotes: 0