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');
개발자 모드에서 확장 프로그램 페이지로 이동하면 '_generated_background_page.html' 링크가 있습니다. 클릭하면 devtools에서 배경 페이지를 볼 수 있습니다. – BeardFist
또 다른 것은'document.write ('hello');를'console.log ('hello');'로 대체해야한다는 것입니다. 이것은 "전경 페이지"가 아닌 "배경 페이지"이기 때문에'document.write()'에서 아무 것도 볼 수 없습니다. –