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

122
Views
cómo redirigir una página html en javascript

Estoy trabajando en la página de Javascript para mi formulario de registro. Simplemente no puedo entender cómo hacer que la página se redirija a otra página si todo está completo.

 document.getElementById("check").onclick = function() { let allAreFilled = true; document.getElementById("myForm").querySelectorAll("[required]").forEach(function(i) { if (!allAreFilled) return; if (!i.value) allAreFilled = false; if (i.type === "radio") { let radioValueCheck = false; document.getElementById("myForm").querySelectorAll(`[name=${i.name}]`).forEach(function(r) { if (r.checked) radioValueCheck = true; }) allAreFilled = radioValueCheck; } }) if (!allAreFilled) { alert('Fill all the fields'); } else { window.location.replace("http://www.w3schools.com"); } };
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Estoy dando mi script de muestra para el mismo problema posible, espero que esto ayude

HTML

 <pre> <!DOCTYPE HTML> <html> <body> <p id=P >Fill in all checkboxes</p> <form> <input type=radio /> <label>Check 1</label> <input type=radio /> <label>Check 2</label> <input type=radio /> <label>Check 3</label> </form> </body> </html> </pre>

JavaScript

 window.onload = () => { var radio = document.querySelectorAll('[type=radio]'), p = document.getElementById("P"); radio.forEach( function(i) { i.onchange = () => { var checked = document.querySelectorAll("[type=radio]:checked"), leftover = radio.length - checked.length; p.innerHTML = "leftover checkbox " + leftover; if(radio.length == checked.length) { alert("All checked"); window.location.href = "https://ilhamb.com/"; } } } ) }
about 4 years ago · Juan Pablo Isaza Report

0

Use window.location.href para redirigir dentro de la misma pestaña/ventana o use window.open() para redirigir a una nueva pestaña/ventana.

Como señaló Quentin, ya está utilizando una forma adecuada de redirigir. ¿Puedo sugerir abrir la consola y verificar si hay errores en la consola? También asegúrese de que su programa realmente llegue a la redirección mediante el uso de un punto de interrupción del navegador o registros de la consola.

about 4 years ago · Juan Pablo Isaza Report

0

este codigo

 window.location = "w3schools.com"

O

 window.location.href = "w3schools.com"

Deberías hacerlo

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!