我正在创建一个 chrome 扩展,但在使用通知webkit 时遇到了一些困难。当我尝试显示通知时,会引发异常:
未捕获的错误:SecurityError:DOM 异常 18
波纹管遵循我的Javascript 代码:
var icon = 'icon_48.png';
var title = 'Test Plugin';
var body = message;
var popup = window.webkitNotifications.createNotification(icon, title, body);
popup.show();
下面跟着我的manifest.json:
{
"name": "Test Plugin",
"version": "1.0.6",
"manifest_version": 2,
"description": "This is a test",
"browser_action": {
"default_icon": "images/icon_32.png",
"default_popup": "popup.html"
},
"icons": {
"128": "images/icon_128.png",
"16": "images/icon_32.png",
"48": "images/icon_48.png"
},
"permissions": [
"http://*/*",
"https://*/*",
"contextMenus",
"tabs",
"notifications",
"management",
"webRequest"
],
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["webtoolkit-sha1.js","content.js"],
"run_at": "document_end",
"css" : ["css/style.css"]
}
],
"web_accessible_resources": ["webtoolkit-sha1.js","inject.js","icon_48.png"]
}
我究竟做错了什么?
谢谢大家!
信息更新:
manifest.json在权限部分有属性通知,但是当我打印webkitNotifications.checkPermission()结果为 1 (PERMISSION_NOT_ALLOWED)。