Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

429
Views
Intentar redirigir la página después de la validación de inicio de sesión usando javascript y html, no funcionará

Entonces, solo comencé a codificar en html y js, necesito ayuda sobre por qué la página no se redirige después de la validación. La página simplemente se restablece después de iniciar sesión y estoy tratando de que se redirija a login.html. ¿Alguna ayuda por favor?

 DOCTYPE html> <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <title>Task Manager</title> <link rel="stylesheet" href="style.css"> <script src ="login.js"> </script> </head> <body> <div class="center"> <h1>Task Manager</h1> <form method="post"> <div class="txt_field"> <input type="text" required name="" id="username"> <span></span> <label>Username</label> </div> <div class="txt_field"> <input type="password" name="" id="password"> <span></span> <label>Password</label> </div> <div class="pass">Forgot Password?</div> <input type="submit" name="" value="Login" onclick="validate()"> <div class="signup_link"> Not a member? <a href="#">Signup</a> </div> </form> </div> </body> </html>

JavaScript:

 function validate() { var username=document.getElementById("username").value; var password=document.getElementById("password").value; if(username=="admin"&& password=="user") { alert("login succesfully"); window.location.href = "./todo.html"; return false; } else { alert("login failed"); return false; } }
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Su problema está en el script de Java en la parte de retorno, por lo que no recuerdo exactamente cómo finalizar la redirección en verdadero

about 4 years ago · Juan Pablo Isaza Report

0

Puede cambiar window.location.href = "./todo.html"; a window.location = "./todo.html";

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!