2016-05-25 2 views
2

Chromeの通知を作成するGoogle Chromeのブラウザ拡張コンテキストメニューのドロップダウンメニューをユーザーがクリックしたときに表示されるようにしようとしています。私が間違っていることについての洞察は非常に高く評価されます。Chromeを「Rich Notification」APIをドロップダウンメニューに接続する

サイドノート:これはすべて、クリックするとポップアップボックスを開くChrome Navbarのデフォルトのポップアップに接続されています。

chrome.runtime.onInstalled.addListener(function() { 
    var context = "selection"; 
    var title = "Add To test"; 
    var id = chrome.contextMenus.create({"title": title, "contexts":[context], 
     "id": "context" + context}); 
}); 

var options = { 
    type: "basic", 
    title: "Primary Title", 
    message: "Primary message to display", 
    iconURL: "test_logo.png" 
}; 

chrome.contextMenus.onClicked.addListener(function() { 
    chrome.notifications.create(options, blarg); 
}); 

function blarg() { 
    console.log("Pop UP FOR LIFE"); 
} 

答えて

1
var options = { 
    type: "basic", 
    title: "Primary Title", 
    message: "Primary message to display", 
    iconUrl: "test_logo.png" 
}; 

あなたはiconUrliconURLを変更する必要があります。変更通知の後にworkとなります。

chrome.notifications | examples

+0

お返事ありがとうございますが、私はまだこのエラーが発生しています: "contextMenusのイベントハンドラでエラーが発生しました:TypeError:プロパティ '未定義の'を作成できません。 – Shawn

+0

適切な権限がありません。マニフェストパーミッションには '' contextMenus''と '' notifications''が必要です。 – Xan

+0

ありがとうございました! – Shawn

関連する問題