Safari应用程序扩展:工具栏弹出JavaScript未运行



我试图构建一个Safari应用程序扩展。javaScript popup.js不会为工具栏图标运行。popup.html将正确显示。

popup.html

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="popup.js"></script>
<link rel="stylesheet" href="popup.css">
</head>
<body>
<strong>Hello World!</strong>
</body>
</html>

popup.js

alert("Test");

manifest.json

{
"manifest_version": 2,
"default_locale": "en",
...

"background": {
"scripts": [ "background.js" ],
"persistent": true
},
...

"browser_action": {
"default_popup": "popup.html",
"default_icon": {
"16": "images/toolbar-icon-16.png",
"19": "images/toolbar-icon-19.png",
"32": "images/toolbar-icon-32.png",
"38": "images/toolbar-icon-38.png"
}
},
"permissions": ["notifications",
"create",
"tabs"]
}

我通过移动身体部位的<script src="popup.js"></script>来解决问题:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="popup.css">
</head>
<body>
<strong>Hello World!</strong>
<script src="popup.js"></script>
</body>
</html>

相关内容

  • 没有找到相关文章

最新更新