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

233
Vistas
windw.location.href not working on localhost

window.location.href is not working for me :/ everthin is running on a localhost with "xampp"

//javascript function 1
function onLogin() {
    window.location = "http://localhost:4000/deletetable";
    console.log("running...");
    console.log(window.location.href);
    return false;
}


// !node.js! function 2 in other file(server.js)
//Delete Table
app.get('/deletetable', (req, res) =>{
    let sql = 'DROP TABLE IF EXISTS users';
    db.query(sql, (err, result) => {
        if(err) throw err;
        console.log(result);
    });
});


//html...
<form onsubmit="onLogin();">
    <div class="wrapper">
       <button class="downloaded-btn"></button>
    </div>
</form>
//only a button...

I tried everthing in the url window.location.href = "url" but nothing works. Thanks for help!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you would like to allow the user to navigate backwards, use window.location.assign = "http://localhost:4000/deletetable"

https://www.w3schools.com/jsref/met_loc_assign.asp

//javascript function 1
function onLogin() {
  console.log("running...");
  return window.location.assign="http://localhost:4000/deletetable";
}


// !node.js! function 2 in other file(server.js)
//Delete Table
app.get('/deletetable', (req, res) =>{
    let sql = 'DROP TABLE IF EXISTS users';
    db.query(sql, (err, result) => {
        if(err) throw err;
        console.log(result);
    });
});


//html...
<form onsubmit="onLogin();">
    <div class="wrapper">
       <button class="downloaded-btn"></button>
    </div>
</form>
//only a button...

Otherwise, if you do not want to allow the user to navigate backwards, use: window.location.replace = "http://localhost:4000/deletetable"

https://www.w3schools.com/jsref/met_loc_replace.asp

//javascript function 1
function onLogin() {
 console.log("running...");
 return window.location.replace ="http://localhost:4000/deletetable";
}


// !node.js! function 2 in other file(server.js)
//Delete Table
app.get('/deletetable', (req, res) =>{
    let sql = 'DROP TABLE IF EXISTS users';
    db.query(sql, (err, result) => {
        if(err) throw err;
        console.log(result);
    });
});


//html...
<form onsubmit="onLogin();">
    <div class="wrapper">
       <button class="downloaded-btn"></button>
    </div>
</form>
//only a button...

about 4 years ago · Juan Pablo Isaza 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