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

193
Views
El botón onclick en html ha dejado de funcionar

Estaba creando un sitio web que usaba una ventana emergente para iniciar sesión. Cuando hago clic en el botón, no funcionó. ¿Cómo solucionar este problema?

Código aquí:

 <style> button { background-color: #04AA6D; color: white; padding: 14px 20px; margin: 8px 0; border: none; cursor: pointer; width: 100%; } </style> <script> function myFunction() { let person = prompt("Please enter your username:", ""); if (person == null || person == "") { text = "User cancelled the prompt."; } else if (person == "hi" || person == "test" || person == "1234") { window.location.href = "youtube.com/c/呂殿下"; } else { window.location.href = "youtube.com"; } </script> <button onclick="myFunction();">Click me</button> </body></html>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Su función tenía un par de errores:

  • soltero = en primer else if
  • sin cerrar } para el bloque else

Para que la bifurcación sea visible, estoy cerrando la sesión en la ubicación en lugar de configurar window.location.href para este ejemplo.

 var text; function myFunction() { let person = prompt("Please enter your username:", ""); if (person == null || person == "") { text = "User cancelled the prompt."; } else if (person == "hi" || person == "test" || person == "1234") { console.log("setting href to sites.google.com/"); //window.location.href = "sites.google.com/"; } else { console.log("setting href to google.com"); //window.location.href = "google.com"; } }
 button { background-color: #04AA6D; color: white; padding: 14px 20px; margin: 8px 0; border: none; cursor: pointer; width: 100%; }
 <button onclick="myFunction()">Click me</button>

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!