【发布时间】:2017-07-08 20:00:14
【问题描述】:
我的简单 chrome 扩展程序不起作用。具体来说,当我单击弹出窗口中的按钮时,不会显示任何警报。 这是我的 manifest.json:
{"manifest_version": 2,
"name": "Getting started example",
"description": "This extension shows a Google Image search result for the current page",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": [
"activeTab",
"<all_urls>"
],
"web_accessible_resources": ["page.js"]}
还有我的 popup.html:
<!DOCTYPE html>
<html>
<head>
<script src="popup.js"></script>
</head>
<body>
<button onclick = "a()">Alert!!</button>
</body>
</html>
还有我的 popup.js:
function a(){
chrome.tabs.executeScript({code: "page.js"});
}
最后,我的 page.js:
alert("Hi from an extension!!");
但没有出现警报框。发生了什么?
【问题讨论】:
标签: javascript html google-chrome-extension