jsp页面 两个 iframe之间传值问题

一个main.jsp里面放2个iframe,id分别是manage和list,src分别是A.jsp,B.jsp,
我想在A中点击a链接之后,传递数据给B页面,然后B页面根据这些数据来查询数据库,将返回相关数据
现在问题是,
怎样传值呢?
传值之后,B页面怎么知道已经传值过来了,怎么接受值呢?
接受之后怎么刷新main.jsp里面的B页面呢?
刚刚学这个家伙,摸不到头脑,请大家帮帮忙
A.jsp
 <script language="javascript">
function win(a,b) {
  opener.setValue1(a);
  opener.setValue2(b);
} </script>
<input type="hidden" name="Id" value="<%=Id%>">
<input type="hidden" name="Name" value="<%=Name%>">
<a href= B.jsp?Id=<%= dis.getId()%> & Name=<%= dis.getName()%> onclick="win(Id.value,Name.value)" > A</a>

B.jsp
function setValue1(m_strValue){
           document.getElementById("Id").value = m_strValue;            }            function setValue2(mstrValue){             document.getElementById("Name").value = mstrValue; } <input type = text name=Id ><input type = text name=Name>怎么传不过来呢??? 3Q

jsp页面子页面像父页面的iframe传值:
1:document.getElementById("ii").contentWindow 得到iframe对象后,就可以通过contentWindow得到iframe包含页面的window对象,然后就可以正常访问页面元素了;
2:$("#ii")[0].contentWindow 如果用jquery选择器获得iframe,需要加一个【0】;
3:$("#ii")[0].contentWindow.$("#dd").val() 可以在得到iframe的window对象后接着使用jquery选择器进行页面操作;
4:$("#ii")[0].contentWindow.hellobaby="dsafdsafsdafsdafsdafsdafsadfsadfsdafsadfdsaffdsaaaaaaaaaaaaa"; 可以通过这种方式向iframe页面传递参数,在iframe页面window.hellobaby就可以获取到值,hellobaby是自定义的变量;
5:在iframe页面通过parent可以获得主页面的window,接着就可以正常访问父亲页面的元素了;
6:parent.$("#ii")[0].contentWindow.ff; 同级iframe页面之间调用,需要先得到父亲的window,然后调用同级的iframe得到window进行操作;
实例代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>显示图表</title>
<script src="/jquery-1.7.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
var gg="dsafdsafdsafdsafsdaf";
function ggMM() {
alert("22");
}
function callIframeMethod() {
//document.getElementById("ii").contentWindow.test();
$("#ii")[0].contentWindow.test(); //用jquery调用需要加一个[0]
}
function callIframeField() {
alert($("#ii")[0].contentWindow.ff);
}
function callIframeHtml() {
alert($("#ii")[0].contentWindow.$("#dd").val());
//alert($("#ii")[0].contentWindow.document.getElementById("dd").value);
//alert($("#ii")[0].contentWindow.document.getElementById("dd").value);
}
function giveParameter() {
$("#ii")[0].contentWindow.hellobaby="dsafdsafsdafsdafsdafsdafsadfsadfsdafsadfdsaffdsaaaaaaaaaaaaa";
}
</script>
</head>
<body>
<a href="#" onClick="giveParameter();">参数传递</a>
<a href="#" onClick="callIframeMethod();">调用子iframe方法</a>
<a href="#" onClick="callIframeField();">调用子iframe变量</a>
<a href="#" onClick="callIframeHtml();">调用子iframe组件</a></br>
<iframe id="ii" src="frame.htm" width="100%" frameborder="0"></iframe>
<iframe id="new" src="newFrame.htm" width="100%" frameborder="0"></iframe>
</body>
</html>
温馨提示:内容为网友见解,仅供参考
第1个回答  推荐于2017-11-25
在你点击A中的a链接之后,就开始像服务器发送请求,将A中的数据提交到服务器,下一步如果提交成功,服务器再A页面中增加一句Javascript代码类似于"B.jsp所在的iframe.open("b.jsp")",然后b.jsp向服务器发送请求,在服务器中得到刚才A提交上去的数据,然后查询,然后返回数据到浏览器b.jsp子页面

或者更简单之间将A页面的数据用Javascript放入B.jsp页面,就在客户端完成这一步,然后B.jsp像服务器发送请求就好了。追问

追问 能写的字数太少了 向你请教的问题在问题补充里 你帮忙看下3Q啦啦

本回答被提问者采纳