2
我正在爲論壇構建Chrome擴展,但問題在於我的popup.html的JavaScript不會執行任何操作。我在頂部添加了警報(「popup.js running ...」),它確實出現了,但彈出窗口根本不顯示。這是一個問題,因爲JavaScript將被要求用於彈出頁面。我有點失落,所以我假設我只是錯過了阻止我的JavaScript運行的東西。我聽說AdBlock擴展會阻止它運行,但我刪除了它,但仍然無法工作。任何人都看到問題?Chrome擴展程序不會從彈出文件中加載我的JavaScript
的manifest.json
{
"name": "Riggy",
"short_name": "Riggy",
"description": "Create your own Roblox Forum signature with Riggy!",
"version": "0.0.1",
"manifest_version": 2,
"browser_action": {
"default_popup": "popup/popup.html"
},
"permissions": [
"storage"
],
"content_scripts": [
{
"matches": ["http://www.roblox.com/*"],
"js": ["scripts/jquery.js", "scripts/content.js"]
}
]
}
popup.html
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="popup.css" />
<script type="text/javascript" src="scripts/jquery.js"></script>
</head>
<body>
<span class="title">Riggy</span><br />
<span>Signature: </span><input name="siggy" id="siggy" value="Riggy is greatness!" />
<span id="output">[output]</span>
<script type="text/javascript" src="popup.js"></script>
</body>
</html>
popup.js
alert("popup.js running");
$(document).on("ready", function() {
var siggy = $("#siggy");
var output = $("#output");
function message(text) {
output.html(text);
}
siggy.change(function() {
chrome.storage.sync.set({"siggy": siggy.val()}, function() {
message("Saved signature.");
});
});
message("Riggy is ready!");
});