Google chrome extension 基于通知类型的chrome扩展通知onclick事件操作
我有两个不同的函数来创建chrome.notification,我希望onclick操作也可以分开。当我浏览chrome扩展API时,没有提到如何处理这种情况 下面是我在background.js中的代码Google chrome extension 基于通知类型的chrome扩展通知onclick事件操作,google-chrome-extension,Google Chrome Extension,我有两个不同的函数来创建chrome.notification,我希望onclick操作也可以分开。当我浏览chrome扩展API时,没有提到如何处理这种情况 下面是我在background.js中的代码 chrome.notifications.onClicked.addListener(function(event){ chrome.tabs.create({url: 'details.html?id=' + event}); }); 为每个通知分配不同的id,并在以下列表中检查该id
chrome.notifications.onClicked.addListener(function(event){
chrome.tabs.create({url: 'details.html?id=' + event});
});
为每个通知分配不同的id,并在以下列表中检查该id:
chrome.notifications.onClicked.addListener(function(notifId){
if (notifId == "notification_1") {
//handle notification 1 being clicked
}
if (notifId == "notification_2") {
//handle notification 2 being clicked
}
//etc.
});