【发布时间】:2013-03-12 11:03:38
【问题描述】:
我正在创建一个 chrome 扩展,但我在使用 通知 webkit 时遇到了一些困难。当我尝试显示通知时,抛出异常:
未捕获的错误:SecurityError: DOM Exception 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 在 permissions 部分具有 notifications 属性,但是当我打印 webkitNotifications.checkPermission() 时,结果为 1 (PERMISSION_NOT_ALLOWED )。
【问题讨论】:
标签: google-chrome google-chrome-extension webkit