JavaScript post request like a form submit向您展示了如何提交在JavaScript中通过POST创建的表单.下面是我修改后的代码.
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();
我想做的是在一个新窗口中打开结果.我目前正在使用类似这样的工具在新窗口中打开页面:
onclick = window.open(test.html, '', 'scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,status=no');