2012-02-23 3 views
1

이해가 안되지만 api의 Google 크롬을 인식하지 못하는 것 같습니다.Chrome 확장 프로그램 : '배경 페이지'콘솔에서이 오류가 발생하는 이유는 무엇입니까?

매니페스트 :

{ 
    "name": "First Extension", 
    "version": "1.0", 
    "description": "The first extensione tha I made", 
    "permissions":["contextMenus"], 
    "background_page": "background_page.html" 
} 

배경 페이지 :

<!doctype html> 
<html> 
    <head> 
    <title>Background Page</title> 
    <script src="script.js"></script> 
    </head> 
    <body> 
    </body> 
</html> 

자바 스크립트 (script.js가) :

if (window.webkitNotifications) { 
    console.log("Notifications are supported!"); 
} 
else { 
    console.log("Notifications are not supported for this Browser/OS version yet."); 
} 
/////////// BROWSER CONTEXT MENU //////////////// 
var arr_context = ["all", "page", "frame", "selection", "link", "editable", "image", "video", "audio"]; 
for(i=0; i<arr_context.length; i++){ 
    var title = arr_context[i]; 
    var menu1 = chrome.contextMenus.create({"type":"normal", "title":"Menu "+title, "contexts":arr_context, "onclick":callBack }); 
} 


function callBack(info, tab){ console.log(info.menuItemId+"; URL: "+tab.url); } 

기능 "콜백 (정보 탭)"쓰지 않는다 아무것도. 배경 페이지에 오류가 있습니다. 오류 : Uncaught TypeError: Cannot call method 'create' of undefined입니다.

모든 파일은 다음과 같습니다.

확장 탭에서 페이지에 액세스하지 못했기 때문에 인터넷에서 실수를 읽었습니다. 그러나 background_page.html을 두 번 클릭하면 .... '많이 무거워요? -.- °

+0

'chrome : // extensions'에서'background_page' 콘솔을 열면'chrome.contextMenues'가 정의되어 있습니다.'chrome.contextMenues.create()'를 수동으로 호출 할 수 있습니까? – abraham

+0

' ** chrome.contextMenues() ** 오류 : 개체 [개체 개체] 가지고있는 방법'contextMenues 없음 ' 크롬 ** ** 개체 ** chrome.contextMenues.create(); ** TypeError : 정의되지 않은 'create'메서드를 호출 할 수 없습니다. ' – Donovant

+1

'chrome.contextMenus'는 'chrome.contextMenus()'가 아닙니다. 업데이트 : 죄송합니다. 'contextMenus'를 잘못 입력 한 첫 번째 주석에 오타가있었습니다. 다시 시도하십시오. – abraham

답변

1

chrome.contextMenus가 여전히 '정의되지 않음'인 경우 Chrome 확장 프로그램을 제거한 다음 다시 설치해야합니다. 이상한 캐싱이 발생할 수 있습니다. 개발 중에 (즉, 코드를 바꿀 수 있고 확장 기능을 다시 트리거 할 때 변경 사항을 볼 수있는) 몇 가지 사항이 업데이트되고, 나머지는 완전히 다시 설치해야합니다 - HTH.

관련 문제