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