我正在使用createHTMLNotification
進行Chrome擴展。通知的html包含一個鏈接。我試圖弄清楚的是如何在點擊鏈接時關閉通知。我的代碼如下關閉html5單擊鏈接時的HTMLNotification
var notification = window.webkitNotifications.createHTMLNotification(
"notification.html"
);
notification.show();
notification.html頁面上的代碼填充數據。該頁面包含jquery庫。當我嘗試做:
$('#title > a').click(function() {
notification.cancel();
}
這當然不起作用,因爲通知未知此html頁面上。我也嘗試在創建通知的代碼的第一部分執行notification.onshow
,但這並沒有產生任何結果。