1 function openPostWindow(url, data, name) { 2 var tempForm = document.createElement("form"); 3 tempForm.id = "tempForm1"; 4 tempForm.method = "post"; 5 tempForm.action = url; 6 tempForm.target = name; //_blank 7 for (var i in data) { 8 //data 为$("#form").serializeArray()的结果 9 var hideInput = document.createElement("input"); 10 hideInput.type = "hidden"; 11 hideInput.name = data[i].name; 12 hideInput.value = data[i].value; 13 tempForm.appendChild(hideInput); 14 } 15 16 17 // window.open(‘about:blank‘, name, ‘height=400, width=400, top=0, left=0, toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes,location=yes, status=yes‘); 18 19 //添加临时form 20 document.body.appendChild(tempForm); 21 //必须手动的触发,否则只能看到页面刷新而没有打开新窗口 22 tempForm.submit(); 23 24 //移除临时创建的form 25 document.body.removeChild(tempForm); 26 27 }
原文地址:https://www.cnblogs.com/lpp-xjj/p/11457952.html
时间: 2024-10-10 10:28:20