windw.location.href不在Local主机上工作

发布于 2025-01-17 15:00:52 字数 812 浏览 0 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

差↓一点笑了 2025-01-24 15:00:52

如果您想允许用户向后导航,请使用window.location.assign =“ http:// localhost:4000/deletetable

” “ rel =“ nofollow noreferrer”> 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...

否则,如果您不想允许用户向后导航,请使用: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...

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文