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

236
Views
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 answers
Answer question

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 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!