Search code examples
google-chrome-extensionhtml5-notificationswebkit-notifications

How to include a link in a Webkit notification?


I am creating a Chrome extension and I am using the Webkit notifications API. I need to show a link in the notification, but the problem is that now Webkit HTML notifications are deprecated, so I only can use notifications with a simple message. I mean, one year ago I could have created a Wbkit HTML notification and include the "a" element, but now I can't.

Is there a way to show a link in a Webkit notification? Thanks.


Solution

  • To make a webkit notification a link, do this (I'm using jQuery for events just because it's easier):

    var notification = window.webkitNotifications.createNotification(
      "http://www.google.com/images/logo.png", // icon url - can be relative
      "Google", // notification title
      "is the best search engine. Click to find out more"  // notification body text
    );
    // Show the notification, I'm assuming notifications are supported and allowed
    notification.show();
    
    jQuery(notification).click(function(){
        window.location = "http://www.google.com";
    });