2012-06-07 2 views
0

문제가, 그리고 그런게 내가 무슨 대답이 여기에 무엇을 찾는 :/내용 스크립트 알림

매니페스트 :

{ 
    "name": "Item Sniper", 
    "version": "1.0", 
    "description": "Sniper", 
    "browser_action": { 
    "default_icon": "face.png", 
    "default_title": "Sniper" 
    }, 
    "background": { 
    "scripts": ["background.js"] 
    }, 
    "permissions": [ 
    "tabs", 
    "notifications", 
    "http://*/*" 
    ] 
} 

Background.js :

chrome.browserAction.onClicked.addListener(function(tab) { 
    chrome.tabs.executeScript(null,{file: "buy.js"}); 
    } 
); 
chrome.extension.onRequest.addListener(
    function(request, sender, sendResponse) { 
    var notify = webkitNotifications.createNotification(
     'face.png', // icon url - can be relative 
     'Hello!', // notification title 
     'Oh hellow!' // notification body text 
    ); 
}); 

Buy.js을 [더 많은 것이 있지만 알림 부분입니다] :

chrome.extension.sendRequest({msg: "Sup?"}, function(response) { // optional callback -  gets response 
    console.log(response.returnMsg); 
}); 
,

나는 기본적으로 콘텐츠 스크립트가 통지를 만들려하지만, 배경으로 JS 스크립트를 고집하면서 수 있다면 나는 몰랐어요 다음 background property가 아니라 어떤 도움/

감사합니다, 알렉스

+3

당신이 시도 했습니까? – Oliver

+0

'하지만 배경으로 js 스크립트를 고수하는 것이 가능한지 알지 못했습니다. 왜 작동하지 않을까요? 테스트 해 봤어? –

답변

0

version 2을 사용하는 매니페스트에서 사용할 수 있습니다. 이 기능을 지원하려면 매니페스트를 다음과 같이 업데이트해야합니다. 크롬 이상이 버전을 대상으로 할 때 나는 또한 18 매니페스트 버전 2로 minimum_chrome_version 속성을 설정

{ 
    "name": "Item Sniper", 
    "version": "1.0", 
    "description": "Sniper", 
    "manifest_version": 2, 
    "minimum_chrome_version": "18", 
    "browser_action": { 
    "default_icon": "face.png", 
    "default_title": "Sniper" 
    }, 
    "background": { 
    "scripts": ["background.js"] 
    }, 
    "permissions": [ 
    "tabs", 
    "notifications", 
    "http://*/*" 
    ] 
} 

공지 사항에만 사용할 수 있습니다.

0

나는 notify.show()를 호출하지 않았다. 당신의 background.js에

chrome.extension.onRequest.addListener(
    function(request, sender, sendResponse) { 
    var notify = webkitNotifications.createNotification(
     'face.png', // icon url - can be relative 
     'Hello!', // notification title 
     'Oh hellow!' // notification body text 
    ); 
    notify.show(); 
}); 

http://code.google.com/chrome/extensions/notifications.html#api

관련 문제