javascript无法用于Chrome扩展程序

时间:2017-10-10 06:31:14

标签: javascript google-chrome-extension

我是chrome扩展开发的初学者。我的问题不过是警报框没有出现,我认为当我将应用程序作为扩展程序运行时,javascript块本身不起作用。但是当我单独运行HTML文件时,它在firefox和chrome浏览器中运行正常。有谁可以帮助我?

清单代码

{
"name": "Intruder",
"description": "Monitoring all your activities.",
"version": "1.1",
"permissions": [
"tabs", "http://*/*", "https://*/*"
],
"browser_action": {
  "default_title": "Watching you",
  "default_icon": "badge.png",
  "default_popup": "popup.html"
},
"manifest_version": 2
}

HTML代码

<html>
<head>
    <title>Intruders World</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width">
    <link rel="stylesheet" href="style.css">
    <script src="jscript.js"></script>
</head>
<body style="background-color: whitesmoke">
    <script>
        function myFunction() {
            var x = document.forms["myForm"]["username"].value;
            if (x == "") {
                window.alert("u have to enter it");
                document.getElementById("demo").innerHTML = "box must be filled!";
                return false;
            }
        }
    </script>
    <p id="demo">Password Locker</p>
    <form name="myForm">
        Media Name:<br>
        <input type="text" name="medianame">
        <br>
        User name:<br>
        <input type="text" name="username">
        <br>
        Type Password:<br>
        <input type="password" name="passwd">
        <br>
        Re-type Password
        <input type="password" name="repasswd">
        <br><br>
        <input type="submit" value="Save" onclick="myFunction()">
    </form>
</body>
</html>

css代码

input[type=submit] {
    background-color: #404040;
    border: none;
    color: white;
    padding: 10px 22px;
    text-decoration: none;
    margin: 4px 2px;
    cursor: pointer;
    border-radius: 30px;
}

0 个答案:

没有答案