Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

308
Vistas
Javascript redirect function is not redirecting
function myFunction() {
  location.replace("https://www.w3schools.com")
}

in the script tag

  <button onclick='myFunction()'>Submit</button>

in the html

Any idea why this very basic command doesn't work?

about 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

check this example: https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_redirect_webpage

If your button is inside the form then need to specify as type of button

<form>
 <button onclick="myFunction()" type="button">Replace document</button>
</form

about 4 years ago · Santiago Trujillo Denunciar

0

I tested your code and it works fine.. Try clearing your cache inspect and right click on reload choose clear cache.

Did u link your script file ?

<script src="script.js"></script>
about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda