Vue中在新窗口打开页面
Vue中在新窗口打开页面//post新窗口打开// var newWin = window.open('','','height=500,width=1250,top=100,left=100,center=yes'),var newWin = window.open('_blank'),formStr = '',formStr ='<form style="vi...
·
Vue中在新窗口打开页面
注意:如需当前窗口打开,form的target属性要设置为’_self’
//post新窗口打开
// var newWin = window.open('','','height=500,width=1250,top=100,left=100,center=yes'),
var newWin = window.open('_blank'),
formStr = '',
formStr =
'<form style="visibility:hidden;" method="POST" action="https://wwww.test.com/api">'+
'<input style="hidden" name="aa" value="'+response.data.aa+'" />'+
'<input style="hidden" name="bb" value="'+response.data.bb+'" />'+
'<input style="hidden" name="cc" value="'+response.data.cc+'" />'+
'<input style="hidden" name="dd" value="'+response.data.dd+'" />'+
'</form>';
newWin.document.body.innerHTML = formStr;
newWin.document.forms[0].submit();
//post新窗口打开方式二
var temp_form = document.createElement("form");
temp_form.action = "https://wwww.test.com/api";
temp_form.target = "_blank";
temp_form.method = "post";
temp_form.style.display = "none";
//添加参数
for (var item in obj) {
var opt = document.createElement("textarea");
opt.name = item;
opt.value = obj[item];
temp_form.appendChild(opt);
}
document.body.appendChild(temp_form);
//提交数据
temp_form.submit();
//get新窗口打开
window.open('https://wwww.test.com/api?aa='+ response.data.aa+'&bb='+ response.data.bb+'&cc='+ response.data.cc+'&dd='+ response.data.dd, '_blank')
更多推荐
已为社区贡献6条内容
所有评论(0)