我正在使用javascript構建Chrome擴展標記在瀏覽器中正常工作,同時將相同的html,javascript代碼添加到Chrome擴展沒有響應。 JSON文件:Chrome擴展未對javascript做出響應
{
"name": "SOB",
"version": "1.0",
"manifest_version":2,
"permissions": ["storage",
"activeTab" ],
"icons" : {
"16" : "16.png" ,
"48" : "48.png"
},
"browser_action": {
"default_icon": "Skype Orange.png",
"default_popup": "popup.html"
},
"background": {
"scripts": ["background.js"],
"persistent": true
}
}
Popup.html:
<!doctype html>
<html>
<head>
<title>Getting Started Extension's Popup</title>
<style>
body {
font-family: "Segoe UI", "Lucida Grande", Tahoma, sans-serif;
font-size: 100%;
}
</style>
<script src="background" type="text/javascript"></script>
</head>
<body>
<input type="text" name="value" id="fillIn" />
<input type="submit" value="Submit" onClick="response()"/>
<p id="answer"></p>
<input type="text" name="value" id="input" placeholder="SOB Check" />
<button id="form" onClick="demo()"> Submit</button>
<p id="output"> </p>
<!----------
<div id="status"></div>
<img id="image-result" hidden>
------------>
</body>
</html>
background.js:
function demo()
{
var arra = [] , i = 1, rem ;
var Input =document.getElementById('input').value;
var x = 1;
while(Input > 0)
{
rem = Input%2;
Input = (parseInt(Input/ 2));
arra[i] = rem ;
i++;
}
while (x < 35)
{
if(arra[x] == 1)
{
output.innerHTML +=("SOB "+ x +" Found" +"<br />");
x = x +1 ;
}
else
{
x = x +1 ;
}
}
}
function response() {
var box = document.getElementById("fillIn");
switch (box.value)
{
case '0' : document.getElementById("answer").innerHTML="Successful";
break ;
case '999' : document.getElementById("answer").innerHTML="Other Error No Retry";
break ;
}
}
右擊烏爾擴展的圖標,並點擊彈出式檢查,調試 – Lakshay