Moh*_*eri 2 notifications google-chrome google-chrome-extension
我是第一次创建 Chrome 扩展程序。
我用过chrome.notifications.create,但是没用!这是我的代码:
chrome.storage.sync.get('refresh_time',function(items){
status = $('td.c').next().html();
if (status.trim() == 'SomeText') {
alert('Works');
var opt = {
type: "basic",
title: "Project1",
message: "This is my first extension.",
iconUrl: "icons/icon-128.png"
};
chrome.notifications.create('statusChanged', opt, function(){});
}
})
Run Code Online (Sandbox Code Playgroud)
执行后我收到警报,但chrome通知不起作用!你能告诉我我的代码有什么问题吗?
顺便说一下,我在清单文件中使用了下面的代码。
"permissions" : [
"storage",
"notifications",
"tabs"
]
Run Code Online (Sandbox Code Playgroud)
小智 7
我认为你需要将 iconUrl 设置为 chrome 扩展路径,如下所示:
iconURL: chrome.runtime.getURL("icons/icon-128.png")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3423 次 |
| 最近记录: |