在同一窗口中无法重定向到“ Eyes.html”

时间:2019-03-30 17:16:51

标签: javascript html

正如标题所述,单击登录按钮后,我无法在同一窗口中将窗口重定向到“ Eyes.html”。

我对javascript很陌生,所以我正在寻找帮助

这是html:

<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>kjedelig AF</title>
<link rel="stylesheet" href="Login.css">
</head>
<body oncontextmenu="return false">

<form class="box" action="Login.html" method="post" name="login">
<div class="login">
<h1>login</h1>
<input type="text" name="usrname" placeholder="Username">
<input type="password" name="pswrd" placeholder="Password">
<input type="submit" onclick="check(this.form)" value="Login">
</div>
</form>

<script language="javascript">
function check(form)
{

  if(form.usrname.value == "dd" && form.pswrd.value == "dd")
  {
    window.location= "Eyes.html"
  }
  else
  {
    alert("Iks dette er kjedelig AF :)")
  }
}
</script>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

通过onclick返回功能

<form class="box" action="Login.html" method="post" name="login">
<div class="login">
<h1>login</h1>
<input type="text" name="usrname" placeholder="Username">
<input type="password" name="pswrd" placeholder="Password">
<input type="submit" onclick="return check(this.form)" value="Login">
</div>
</form>
function check(form){
    if(form.usrname.value == "dd" && form.pswrd.value == "dd")  {
    window.location.href= "Eyes.html";
    return false;
    }
    else
    {
    alert("Iks dette er kjedelig AF :)")
    }
    return true;
}