表单提交后的页面重定向可以通过以下几种方式来实现:
上述代码中,content
属性中的0
表示立即跳转,url
属性指定了重定向后的页面URL。
上述代码中,onclick
事件触发了redirect()
函数,函数内使用window.location.href
实现页面重定向。
const express = require('express');
const app = express();
app.get('/', (req, res) => {
res.send(`
`);
});
app.post('/submit', (req, res) => {
// 处理表单提交逻辑
// 重定向到指定页面
res.redirect('/redirected_page.html');
});
app.listen(3000, () => {
console.log('Server is running on port 3000');
});
上述代码中,app.post('/submit')
处理表单提交的POST请求,并使用res.redirect()
方法重定向到指定页面。
注意:以上示例仅供参考,具体实现方式可能根据使用的编程语言、框架或服务器配置而有所不同。