Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
372 views
in Technique[技术] by (71.8m points)

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

JavaScript post request like a form submit shows you how to submit a form that you create via POST in JavaScript.

(像表单提交一样的JavaScript发布请求会向您展示如何提交您在JavaScript中通过POST创建的表单。)

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');
  ask by translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Add

(加)

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

or

(要么)

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

to your form's definition.

(到你的表格的定义。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...