简体   繁体   English

target =“ _ blank”的表单-新窗口和加载页面

[英]Form with target=“_blank” - new window AND loading page

After submiting a form, a new page should open to be printed as pdf. 提交表格后,应打开一个新页面以pdf格式打印。 But by doing it like that <form action="page.php" method="POST" target="_blank"> the form with all the information still exists which is very, very bad. 但是通过像<form action="page.php" method="POST" target="_blank">的方式,仍然存在带有所有信息的表单,这是非常非常糟糕的。 Instead of still showing the page with the form, I would now like to load another page within this windows/tab AND open the print-window. 现在,我不再想显示带有表单的页面,而是想在此窗口/选项卡中加载另一个页面并打开打印窗口。 With php and headers it's not possible, but with javascript should be right? 使用php和标头是不可能的,但是使用javascript应该是正确的吗? But how? 但是如何? I'm not used to javascript, so I have no idea how to handle this problem, but do you have an idea? 我不习惯使用javascript,因此不知道如何处理此问题,但是您有想法吗?

You can attach an onsubmit event to the form, f.ex: 您可以在表单f.ex上附加一个onsubmit事件:

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

This assumes that the form has an ID of "form". 假设表单的ID为“表单”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM