Notification JS, can it be customized?

2

I have followed these steps to make a notification on my website:

link

link

And this is what I have:

$(document).ready(function() {
    theBody = "" +
            "<div style='background: #0055a0; color: #ffffff'>" +
            "   <strong>Tienes nuevos pedidos!</strong>"+
            "</div>";
    theTitle = "<h1>Hay un nuevo pedido</h1>";
    var options = {
        body: theBody,
    };
    var n = new Notification(theTitle,options);
    setTimeout(n.close.bind(n), 15000);
});

And it works, but it shows me the content as plain text, is there any way to customize the colors the background color and the letter?

    
asked by Pavlo B. 09.08.2018 в 17:43
source

1 answer

1

You can add an image by adding

icon:
 "rutadelaimagen"

staying like this:

   
   Notification.requestPermission(function (status) {
        // Si el usuario acepta
        if (status === "granted") {
         var title = 'My Notification';
    var options = {
       icon: 'https://cdn4.iconfinder.com/data/icons/superhero/400/superman.png',
       body: 'nueva notificación'
    };
  var n = new Notification(title,options);
    setTimeout(n.close.bind(n), 1000);
        }

});
  

But these notifications do not allow much more customization since the browser, Chrome, Mozilla, Edge are the ones that give you your own personalization

    
answered by 09.08.2018 / 18:53
source