javascript - Jquery表单提交同时打开新标签
问题描述
我创建了一个 html 表单,在其中使用了这个 html 和 js 代码,这些代码将表单值填充到链接并提交到另一个网站。
<form>
<table width="505" border="1">
<tbody>
<tr>
<td width="324">Your name</td>
<td width="165"><input type="text" name="applicant_UserName" id="name2" /></td>
</tr>
<tr>
<td>Your email address</td>
<td><input type="text" name="applicant_Email" id="email2" /></td>
</tr>
<tr>
<td>Your mobile number</td>
<td><input type="text" name="applicant_mobile number" id="mobile number" /></td>
</tr>
<tr>
<td>What is the name of the person you want to nominate as your guarantor?</td>
<td><input type="text" name="Guarantor applicant_UserName" id="name3" /></td>
</tr>
</tbody>
</table>
<input type="submit" value="Submit" />
和js
$(function(){
$('form').on('submit', function(e){
var out_url = "https://demo.com/PowerFormSigning.aspx?";
e.preventDefault();
var arr = $('input[type="text"]')
.map(function(){
var self = $(this);
return [self.attr('name'),
self.val()
].join('=');
})
.toArray()
.concat($("option:selected").map(function(){
var self = $(this);
return [self.closest('select').attr('name'), self.text()].join('=')
}).toArray()).join('&');
window.location.href = out_url + arr;
})
})
现在我希望通过单击提交来同时打开另一个新选项卡,其中将显示消息“已提交数据”,并带有少量 css 样式。我尝试了一些代码,但它会打开新窗口,有时浏览器会阻止窗口。请帮我解决提交时重定向到新选项卡的问题,并在浏览器中打开带有少量样式的“数据已提交”消息。
解决方案
推荐阅读
- sql - 在 pgadmin/postgresql 中,如何处理文件未被读取且 SQL 状态如下的文件导入问题:58P01
- vue.js - 包含循环引用的对象图上的 Vue 反应性
- python - 我如何导入这些功能?属性错误
- java - 用 Java 确定最优交易行为的遗传算法
- flutter - 需要帮助为我的自定义顶部栏对齐图标
- angular - Angular 材质对话框的 canDeactivate 问题(用作子组件)
- java - 出现错误 GoldfishAddressSpaceHostMemoryAllocator: ioctl_ping failed for device_type=5, ret=-1
- python - 在一组数据点上应用 fft 后如何取回傅里叶级数系数?
- android - 如何将哈希图写入文件并从另一个意图再次读取它
- python - 通过 python (PostgreSQL) 执行 INSERT 语句时出错