显示Chrome扩展程序javascript无法正常工作

时间:2014-07-30 08:11:15

标签: javascript google-chrome-extension manifest google-chrome-devtools

你好,我很高兴我创建了一个清单Chrome扩展浏览器,我创建的javascript函数无效。我想要制作一个简单的登录系统,如果成功,它将转移到另一个html文件。

的login.html

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Order Capture</title>
    <link rel="stylesheet" type="text/css" href="Style.css" />
    <script type="text/javascript" src="LoginFunction.js"></script>
</head>
<body>
    <div id="wrapper">
        <div class="table">            
            <form action="" method="POST" onSubmit="Validate();">
                <table border="1" width="300" height="300">
                    <tr>
                    <thead>LOGIN FORM</thead></tr>
                    <tr><td>Username: </td><td><input type="text" id="username" name="username" /></td></tr>
                    <tr><td>Password: </td><td><input type="password" id="password" name="password" /></td></tr>
                    <tr><td><input type="text" id="btn" onClick="Login();" value="Login" /></td><td><input type="reset" value="Clear"></td></tr>
                </table>
            </form>
        </div>
    </div>
</body>
</html>

LoginFunction.js

function Login() 
{
    location.href = 'Main.html';    
}

function Validate() {
    if (document.forms["myform"]["username"].value == null || document.forms["myform"]["username"].value == "") {
        alert("Username is Empty")
        return false;
    }
    else if (document.forms["myform"]["password"].value == null || document.forms["myform"]["password"].value == "") {
        alert("Password is Empty")
        return false;
    }
    else { return true; }
}

的manifest.json

{
  "manifest_version": 2,

  "name": "Order Capture",
  "description": "This extension Helps Capture Needs for Client",
  "version": "2.0",

  "browser_action": {
    "default_icon": "camera.png", <-- i have the icon already
    "default_popup": "Login.html"
  },
  "permissions": ["https://secure.flickr.com/"] <-- this i don't have idea yet is this important? or the reason why my javascript not working?
}

抱歉,我是新手,并试图在这里做点什么......我真的需要任何人的想法和帮助

问题:即使是一个简单的警报,我也没有接受任何javascript功能(&#39; HELLO&#39;);要放在按钮上它没有出现..它没有接受任何javascript事件我把它全部忽略它但是清除按钮上的重置正在运行。

0 个答案:

没有答案