windw.location.href不在Local主机上工作
window.location.href 对我不起作用:/everthin 正在运行 带有“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...
我尝试了 url window.location.href =“url”
中的所有内容,但没有任何效果。感谢您的帮助!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想允许用户向后导航,请使用window.location.assign =“ http:// localhost:4000/deletetable
” “ rel =“ nofollow noreferrer”> https://www.w3schools.com/jsref/met_loc_assign.asp
否则,如果您不想允许用户向后导航,请使用:window.location.replace =“ http://localhost:4000/deletetable”
https://www.w3schools.com/jsref/met_loc_replace.asp
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
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