gpt4 book ai didi

javascript - 目标为 ="_blank"的表单 - 新窗口和加载页面

转载 作者:行者123 更新时间:2023-11-28 09:31:21 25 4
gpt4 key购买 nike

提交表单后,应打开一个新页面以打印为 pdf 格式。但这样做<form action="page.php" method="POST" target="_blank">包含所有信息的表格仍然存在,这是非常非常糟糕的。我现在想在此窗口/选项卡中加载另一个页面并打开,而不是仍然显示带有表单的页面打印窗口。使用 php 和 headers 是不可能的,但是使用 javascript 应该是正确的?但如何呢?我不习惯 javascript,所以我不知道如何处理这个问题,但是你有想法吗?

最佳答案

您可以将 onsubmit 事件附加到表单,例如:

document.getElementById('form').onsubmit = function() {
window.location = '/anotherpage.html';
}

这假设表单的 ID 为“form”。

关于javascript - 目标为 ="_blank"的表单 - 新窗口和加载页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13684251/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com