I would like to implement same functionality as Gmail has nowadays. When new email arrives or new chat comes, notification popup appears and if you click it, the tab with Gm
It should be this.close() rather than this.cancel(), like this:
this.close()
this.cancel()
var n = window.webkitNotifications.createNotification('ico.gif','Title', 'Text'); n.onclick = function(x) { window.focus(); this.cancel(); }; n.show();