提交 POST 表单后,打开一个显示结果的新窗口 [英] After submitting a POST form open a new window showing the result

查看:34
本文介绍了提交 POST 表单后,打开一个显示结果的新窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

类似于表单提交的 JavaScript 发布请求 向您展示了如何提交您在 JavaScript 中通过 POST 创建的表单.下面是我修改后的代码.

JavaScript post request like a form submit shows you how to submit a form that you create via POST in JavaScript. Below is my modified code.

var form = document.createElement("form");

form.setAttribute("method", "post");
form.setAttribute("action", "test.jsp");

var hiddenField = document.createElement("input");  

hiddenField.setAttribute("name", "id");
hiddenField.setAttribute("value", "bob");
form.appendChild(hiddenField);
document.body.appendChild(form); // Not entirely sure if this is necessary          
form.submit();

我想做的是在新窗口中打开结果.我目前正在使用这样的东西在新窗口中打开一个页面:

What I would like to do is open the results in a new window. I am currently using something like this to open a page in a new window:

onclick = window.open(test.html, '', 'scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,status=no');

推荐答案

添加

<form target="_blank" ...></form>

form.setAttribute("target", "_blank");

到您的表单定义.

这篇关于提交 POST 表单后,打开一个显示结果的新窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆