크롬 확장을 사용하여 새 탭을 만들고 탭을로드 할 때 tab.id
으로 표시하려고합니다. 페이지가로드되었지만 콜백 기능이 작동하지 않습니다 (이제 tab.id
과 함께 경고가 표시됨).chrome.tabs.create - 콜백 함수가 호출되지 않음
background.js 파일 :
chrome.tabs.create({'url': 'http://www.google.com'}, function(tab){ alert(tab.id) })
의 manifest.json 파일 :
{
"name": "Test",
"version": "1.0",
"description": "Test plugin",
"browser_action": {
"default_popup": "popup.html",
"default_icon":"icon.png"
},
"background": {
"scripts": ["background.js"]
},
"manifest_version":2,
"permissions": [
"tabs",
"http://*.facebook.com/*",
"http://*.google.com/*",
"storage"
]
}
popup.html 파일 :
<html>
<head>
<title>Test tabs</title>
</head>
<body>
<script type="text/javascript" src=/background.js"></script>
</body>
</html>
무슨 문제가있을 수 있습니까?
이 코드는 background.js에 있습니다. – shtkuh
예외/오류가 발생합니까? 확장 프로그램을 실행 하시겠습니까? –
확장 페이지에 예외가 없습니다. – shtkuh