在js中window.open通过“post”传递参数

在js中window.open通过“post”传递参数的步骤如下:

如:在A.jsp中 有一个js方法 winow.open,目标地址是 xx.do

1、在A.jsp建一个form,把要设置的值通过js动态添加到里面,如:

$("#postForm").append(‘<input type="hidden" name="query.id" value="12"/>‘);

2、设置form的target属性:

$("#postForm").attr("target","newWin");

3、设置form的action:

$("#postForm").attr("action","<%=path%>/xx/xx.do");

4、window.open:

window.open("about:blank","newWin","");//newWin 是上面form的target

5、提交表单:

$("#postForm").submit();

ok,完成上面5步之后,完整的js方法如下:

function openWin(){
   $("#postForm").html(‘‘);//防止元素重复
   $("#postForm").append(‘<input type="hidden" name="query.id" value="12"/>‘);
   $("#postForm").attr("target","newWin");
   $("#postForm").attr("action","<%=path%>/xx/xx.do");
   window.open("about:blank","newWin","");//newWin 是上面form的target
   $("#postForm").submit();
}

转载自:http://www.thinksaas.cn/news/show/431/
时间: 2024-08-05 23:14:04

在js中window.open通过“post”传递参数的相关文章

关于js中window.location.href,location.href,parent.location.href,top.location.href的用法

关于js中window.location.href,location.href,parent.location.href,top.location.href的用法 "window.location.href"."location.href"是本页面跳转. "parent.location.href" 是上一层页面跳转. "top.location.href" 是最外层的页面跳转. 举例说明: 如果A,B,C,D都是html,D

js中window对象详解以及页面跳转

js中window对象详解以及页面跳转 转自:http://www.makaidong.com/%E5%8D%9A%E5%AE%A2%E5%9B%AD%E6%90%9C/39219.shtml 1.window.top.window.location = "index.asp"; 2.window.top.location.href="index.asp" 3. window.top.location.replace("index.asp");

js中window.self,window.top,window.parent,window.opener

在js中window.self,window.top,window.parent,window.opener四个的作用区别还是很大的, window.self,window.top是打开模式, 而window.parent,window.opener是父窗口打开模式,下面我来介绍介绍. =============================================================== 在应用有frameset或者iframe的页面时, parent是父窗口, top是

js中window.onload 与 jquery中$(document.ready()) 测试

js中window.onload 与 jquery中$(document.ready())区别,验证代码如下(调换js代码和Jquer代码书写顺序测试,运行结果一样,因此与代码书写位置没关系): <html> <head> <script type='text/javascript' src='jquery-1.11.1.min.js'></script> <script type='text/javascript'> $(document).r

关于js中window.location.href,location.href,parent.location.href,top.location.href的使用方法

关于js中"window.location.href"."location.href"."parent.location.href"."top.location.href"的使用方法 "window.location.href"."location.href"是本页面跳转 "parent.location.href"是上一层页面跳转 "top.locatio

关于js中&quot;window.location.href&quot;、&quot;location.href&quot; 等如何跳转

关于js中"window.location.href"."location.href"."parent.location.href"."top.location.href"的用法 "window.location.href"."location.href"是本页面跳转 "parent.location.href"是上一层页面跳转 "top.location.

前端页面js与flash交互——js获取flash对象,并传递参数

背景介绍: 最近在搞一个项目,涉及到图片选取,裁剪,上传等,由于浏览器安全性问题,js无法获取到<input type="file">中选取的文件路径,而且对照片的裁剪,抠图等由HTML5实现的功能,对各大浏览器的兼容性,真是不敢太大胆.这个时候就引进了flash,然后所有js做不了的让flash来做,然后由js来控制页面元素.就这样开始了js与as的交互之旅,听做flash的大叔说,flash调js的函数式很好调的,而js调as不大容易.最终的情况是as调js错误层出不穷

在Linux中利用命令行去传递参数给Python

: 今天在实验楼答题做挑战的时候,遇到个一点都没头绪的题目,链接:https://www.shiyanlou.com/courses/running,题目如上,因为之前没接触到这类型的题目,所以无法入手百度了一下,知道了原来有个sys.argv[]这样的东西用.要从Linux中利用命令行去传递参数给Python文件 1,要先导入系统接口模块import sys 2,再调用系统命令行参数sys.argv,这是一个列表. 索引为0的sys.argv[0]是当前文档的路径,这不是我们想要的.索引为1的

JS中setInterval、setTimeout不能传递带参数的函数的解决方案

在JS中无论是setTimeout还是setInterval,在使用函数名作为调用句柄时都不能带参数,而在许多场合必须要带参数,接下来为大家介绍具体的解决方法 在JS中无论是setTimeout还是setInterval,在使用函数名作为调用句柄时都不能带参数,而在许多场合必须要带参数, 这就需要想方法解决. 一.采用字符串形式:——(缺陷)参数不能被周期性改变 setInterval("foo(id)",1000); 二.匿名函数包装 (推荐) window.setInterval(