2013-03-10 7 views
4

내 크롬 확장 백그라운드 스크립트가로드되지 않습니다. 나는 그들을 위해 Google 가이드를 따라 갔지만 아직도 아무것도하지 않았다. 검사 할 다른 방법이 있는지는 잘 모르겠지만 요소 검사 (Inspect Element)에 있지 않으며 스크립트가 수행해야하는 작업이 일어나지 않아야합니다.크롬 확장 배경 스크립트가로드되지 않습니다.

http://developer.chrome.com/extensions/background_pages.html

의 manifest.json 파일

{ 
"manifest_version": 2, 

"name": "WebDevFriend", 
"description": "blah blah blah", 
"version": "1.0", 

"permissions": [ 
    "bookmarks", 
    "tabs", 
    "http://*/*" ], 

"background": { 
    "scripts": ["js/settings.js"], 
}, 

"browser_action": { 
    "default_icon": "images/icon.png", 
    "default_popup": "html/popup.html" 
} 
} 

settings.js는 일반 HTML 페이지처럼 배경 페이지를 볼 수 없습니다

chrome.windows.onCreated.addListener(function(window){ 
    chrome.windows.getAll(function(windows){ 
     var length = windows.length; 
     if (length == 2) { 
      chrome.tabs.executeScript(null, {file: "content_script.js"}); 
     } 
    }); 
}); 
document.write('hello'); 
+0

개발자 모드에서 확장 프로그램 페이지로 이동하면 '_generated_background_page.html' 링크가 있습니다. 클릭하면 devtools에서 배경 페이지를 볼 수 있습니다. – BeardFist

+1

또 다른 것은'document.write ('hello');를'console.log ('hello');'로 대체해야한다는 것입니다. 이것은 "전경 페이지"가 ​​아닌 "배경 페이지"이기 때문에'document.write()'에서 아무 것도 볼 수 없습니다. –

답변

3

먼저 파일. 유일한 방법은 Chrome 개발자 도구를 사용하여 콘텐츠를 보는 것입니다.

enter image description here

은 브라우저의 확장 섹션에서 generated_background_page.html 클릭합니다.

두 번째 메시지를 기록하려면 console.log() 문을 사용하십시오.

관련 문제