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

93
Vistas
location.href = 'URL' redirects to a new page not a new website

I am trying to make a project that involves redirecting to another website. I am having trouble doing that.

Here is my code

document.getElementById("ContinueToWeb").onclick = function () {
   location.href = "google.com";
}
<html>
  <head>
    <!--Some code here-->
  </head>
  <body>
    <!--Some code here-->
    <button id="ContinueToWeb">Continue</button>
  </body>
</html>

For some reason, it redirects from c:/folder/index.html to c:/folder/google.com even though I am telling it to go from c:/folder/index.html to google.com. Do you know what's happening?

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

0

You have to add the protocol for the link or else it defaults to what the site is using which is your local filesystem. Use https://www.google.com instead

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