Google notification Click event

I am developing a google chrome extension for my site.

I want a user to click on a notification on the Google Chrome desktop to open my site.

So how can I handle the click event on the Chrome Chrome desktop?

+6
google-chrome google-chrome-extension
source share
2 answers

Based on this: http://code.google.com/chrome/extensions/notifications.html I decided like this:

I made a notification.html file:

<html> <head> <base target="_blank" /> </head> <body> <a href="http://example.com">Open site</a> </body> </html> 

And I open the notification with this code:

 var notification = webkitNotifications.createHTMLNotification( 'notification.html' ); notification.show(); 

You can use CSS to make it look like a complete link without text in the notification body.

-3
source share

If you do not want to use the HTML notification, you can add a click event handler to the notification and call the cancel function.

 var notification = window.webkitNotifications.createNotification( 'url', 'title', 'text'); notification.addEventListener('click', function() { notification.cancel(); window.open('url') }) notification.show(); 
+4
source share

All Articles