Chrome 分机未响应 javascript

Chrome extension not responding to javascript

我正在构建一个 chrome 扩展,使用 javascript 标签在浏览器中正常工作,同时将相同的 html ,javascript 代码添加到 chrome扩展没有响应。 Json 文件:

{

"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 ;
}
}

您将需要 运行 DOMContentLoaded 事件

的代码
document.addEventListener('DOMContentLoaded', function () {
  demo();
});

您在弹出 html 文件中引用了 background 而不是 background.js