function openWindowWithPost(url,name,keys,values)
{
var newWindow = window.open(url, name);
if (!newWindow)
return false; var html = "";
html += "<html><head></head><body><form id='formid' method='post' action='" + url + "'>";
if (keys && values)
{
html += "<input type='hidden' name='" + keys + "' value='" + values + "'/>";
} html += "</form><script type='text/javascript'>document.getElementById('formid').submit();";
html += "<\/script></body></html>".toString().replace(/^.+?\*|\\(?=\/)|\*.+?$/gi, "");
newWindow.document.write(html); return newWindow;
}
function openPostWindow(url, data, name)       

  {       

     var tempForm = document.createElement("form");       

     tempForm.id="tempForm1";       

     tempForm.method="post";       

     //url
tempForm.action=url;
//open方法不能设置请求方式,一般网页的post都是通过form来实现的。
//如果仅仅模拟form的提交方式,那么open方法里那种可设置窗体属性的参数又不能用。
//最后想办法整了这么一个两者结合的方式,将form的target设置成和open的name参数一样的值,通过浏览器自动识别实现了将内容post到新窗口中
tempForm.target=name; var hideInput = document.createElement("input"); hideInput.type="hidden"; //传入参数名,相当于get请求中的content=
hideInput.name= "content"; //传入传入数据,只传递了一个参数内容,实际可传递多个。
hideInput.value= data; tempForm.appendChild(hideInput); tempForm.attachEvent("onsubmit",function(){ openWindow(name); }); document.body.appendChild(tempForm); tempForm.fireEvent("onsubmit"); //必须手动的触发,否则只能看到页面刷新而没有打开新窗口
tempForm.submit(); document.body.removeChild(tempForm); } function openWindow(name) { 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'); }

window.open以post方式提交(转)的更多相关文章

  1. 苹果微信浏览器不能post方式提交数据问题

    form表单中采用post方式提交数据时,在苹果的微信浏览器中无法传递,安卓的可以 如图: 在controller中获取该数据为 null 将表单的提交方式修改为get就能够获取到 现在采用Ajax方 ...

  2. 重定向和转向的写法,重定向以post方式提交

    重转向保留跳转过来的Referer,路径不会变1 request.getRequestDispatcher("/eventweb/index.sp?loginId=" + logi ...

  3. 使用post方式提交表单如何获取图片数据及其他文本参数[NodeJS]

    当POST方式提交包含图片的表单时,如上传图片时,需要在<form>字段需要添加参数enctype="multipart/form-data",表明以二进制方式传输数据 ...

  4. get方式提交中文乱码解决

    get方式提交中文时会乱码,过滤器只过滤post请求,此时可修改tomcat配置文件server.xml,为Connector添加属性URIEncoding="utf-8". ec ...

  5. 超链接实现post方式提交

    思路:如果想要超链接实现post方式提交,必须借助表单.下面得两种方式,一种是借助显示的form表单,一种是借助隐式的form表单方式一:将超链接放到一个form表单中,或者超链接本身就在一个form ...

  6. Android 采用post方式提交数据到服务器

    接着上篇<Android 采用get方式提交数据到服务器>,本文来实现采用post方式提交数据到服务器 首先对比一下get方式和post方式: 修改布局: <LinearLayout ...

  7. 导出excel时,以form方式提交json数据

    今天在写项目时写到一个excel的导出,开始想用ajax请求后台后导出,但发现ajax会有返回值,而且ajax无法直接输出文件,而后台的excel导出方法已经封装好,不方便修改. 就改用了提交的方式f ...

  8. easyui form 方式提交数据

    http://ldzyz007.iteye.com/blog/2067540 <form id="ff" method="post">      . ...

  9. http-使用get和post方式提交数据

    注意点: 1.Get和post这两种提交方式有何不同? 很明显post方式提交多了content-length和content-type这两项,所以post提交是要为这两项设置setRequestPr ...

随机推荐

  1. [HNOI2004]宠物收养所

    题目链接:戳我 其实也就是一个splay而已了. 但是一定要注意这种需要计算的,刚开始insert的时候插入极大值极小值的时候不要让它爆掉int.......(比如我刚开始就写了一个214748364 ...

  2. geth attach

    1. geth attachgeth attach ipc:\\.\pipe\geth.ipc2. "Error: insufficient funds for gas * price + ...

  3. [arc076F]Exhausted? 贪心+堆

    Description ​ 有m个椅子,第i个在位置i,每个椅子只能坐一个人.  有n个人,第i个人能坐的椅子的位置j需满足j≤Li或j≥Ri.  现在你可以添加若干个椅子,可以放在任意实数位置.问最 ...

  4. Jupyter Notebook远程服务器配置[转]

    首先要生成密码,打开python终端. In [1]: from IPython.lib import passwd In [2]: passwd() Enter password: Verify p ...

  5. [译文]casperjs使用说明-选择器

    casperjs的选择器可以在dom下工作,他既支持css也支持xpath. 下面所有的例子都基于这段html代码: <!doctype html> <html> <he ...

  6. Azure Powershell获取Azure虚拟机的操作系统型号及具体版本

    Azure ARM 模式虚拟机: 1.登陆Azure账号 Add-AzureRmAccount -EnvironmentName AzurechinaCloud 2.选择指定订阅 Select-Azu ...

  7. virsh 连接虚拟机 (vnc 或 控制台)

    第一种方式 1.如果虚拟机登录方式为VNC,在ubuntu机器上安装vncviewer 在虚拟机的配置xml中 <graphics type="vnc" autoport=& ...

  8. css第二篇:样式的特殊性、重要性、继承和层叠

    特殊性:   假设有几个不同的规则改变的都是同一个元素的值,那么哪一个规则将会胜出呢?这就得靠特殊值啦,什么是特殊值呢?特殊值的大小呢?如下图: 值越大代表越牛,如1,0,0,0永远大于0,X,X,X ...

  9. Visual Studio 2019 激活码

    Visual Studio 2019 Enterprise BF8Y8-GN2QH-T84XB-QVY3B-RC4DF Visual Studio 2019 Professional NYWVH-HT ...

  10. Java转python第二天

    1.dict基本操作 dic = {"name":"张三","age":21} # 增 dic['high'] = 185 # 增加 ,结果 ...