【发布时间】:2017-06-15 01:22:37
【问题描述】:
我正在尝试为 R 闪亮的 Web 应用程序文件创建一个非常简单的密码保护。您在下面看到的代码包含在 index.html 中。在同一个文件夹中有一个名为“testflex.html”的文件。那是我想用密码保护的文件。当我输入用户名和密码时没有任何反应。但是,当我输入错误的用户名或密码时,会显示错误消息。
有什么提示吗? (代码如下)
function showPass(form){
var user = form.username.value;
var pass = form.pwd.value;
var user1 = "admin" // this is the username
var pass1 = "abcd1234" // this is the password
if(user === user1 && pass === pass1){
window.open = "testflex.html";
}
else{
document.write("Wrong password or username");
}
}
</script>
<body>
<form>
Username: <input type="text" name="username" /> <br />
Password: <input type="password" name="pwd" /> <br />
<input type="button" value="Log In" onclick="showPass(form)" /> </form> </body>
【问题讨论】:
-
添加;在 user1,pass1 之后并尝试使用 == 而不是 ===
-
我看到我在代码中有几个错误,但不管解决方案不起作用......无论如何谢谢。
标签: javascript r shiny shiny-server