Google Chrome扩展程序不会输出预期的文字

时间:2016-01-21 00:23:35

标签: javascript html google-chrome google-chrome-extension

我正在创建用于生成密码的Google Chrome扩展程序。它在HTML页面中工作,但在扩展名时,它不会在文本字段中输出密码。 working HTML Pagenon working Extension

Google Chrome扩展程序的工作方式与HTML不同吗?我需要manifest.JSON中的特殊内容吗?

popup.html位于

之下
    <html>
  <head>
    <title>Random Password Generator</title>
    <style>
      body {
        font-family: "Segoe UI", "Lucida Grande", Tahoma, sans-serif;
        font-size: 100%;
      }
      #status {
        /* avoid an excessively wide status text */
        white-space: pre;
        text-overflow: ellipsis;
        overflow: hidden;
        max-width: 1000px;
      }
    </style>

    <!--
      - JavaScript and HTML must be in separate files: see our Content  Security
      - Policy documentation[1] for details and explanation.
      -
      - [1]: https://developer.chrome.com/extensions/contentSecurityPolicy
     -->
    <script src="popup.js"></script>
  </head>
  <body>
    <div id="status"></div>
    <img id="image-result" hidden>
      <form name="pgenerate">
<input type="text" size=18 name="output">
<input type="button" value="Generate Password" onClick="populateform(this.form.thelength.value)"><br />
<b> <font size="1"> Password Length: </font> </b> <input type="text" name="thelength" size=3 value="12">
</form>


  </body>
</html>

popup.js位于

之下
    var keylist="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*().?/`~"
var temp=''

function generatepass(plength){
temp=''
for (i=0;i<plength;i++)
temp+=keylist.charAt(Math.floor(Math.random()*keylist.length))
return temp
}

function populateform(enterlength){
document.pgenerate.output.value=generatepass(enterlength)
}

最后我的表现。

    {
  "manifest_version": 2,

  "name": "Random Password Generator",
  "description": "This extension generates random 20 character strong passwords for you. These passwords includes both lower and upper case letters and special characters. You can copy the password, paste it in password generating window and Google Chrome will save your password if you chose remember my password. This will help in easier log in solutions.",
    "author": "Sheheryar Ahmad",

  "version": "1.0",

  "browser_action": {
    "default_icon": {
        "19": "images/icon19.png",
        "38": "images/icon38.png"
    },
    "default_popup": "popup.html",
    "default_title": "Random Password Generator"

  },
  "permissions": [
    "activeTab",
    "https://ajax.googleapis.com/"
  ]
}

0 个答案:

没有答案