Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

234
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda