之前用window.open(‘*.jsp','',''),然后在子页面用window.opener.document.getElementById("name").value=val;给父页面传值。现在在SSH2中不知道有什么专门的方式,只好也这样用window.open(‘*.action','',''),这样使用在IE和360浏览器中没有问题,在火狐和谷歌浏览器就回报“No result defined for action zypt.view.ProjectAction and result input”的错误。
请哪位大侠给指点一下,子页面传值该怎么做,或者这个问题怎么解决
------解决方案--------------------
window.opener 、应该可以的,检查看看是不是其他影响
------解决方案--------------------
这里有个例子,你可以参考一下。
主页面 test.html 源代码:
<html>
<head>
<mce:script language="JavaScript" type="text/javascript" src="test.js" mce_src="test.js"></mce:script>
</head>
<body>
<input type="button" value="新增" onclick="addTr()">
<table id="mainTable" border=1 >
<tr>
<td align="center"><b>序号</b></td> <td align="center"><b>姓名</b></td> <td align="center"><b>人员关系</b></td> <td align="center"><b>删除</b></td>
</tr>
</table>
</body>
</html>
模态页面 modal.html 源代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>模态</title>
</head>
<body >
<input type="text" id="re" /><button type="button" id="ok" onclick="a();">OK</button>
<mce:script type="text/javascript"><!--
//var obj = window.dialogArguments;
//alert(obj.name);
function a(){
window.returnValue = document.getElementById("re").value;
window.close();
}
// --></mce:script>
</body>
</html>
JS 源文件 test.js 源码:
//在表尾添加一行
function addTr(){
var tableObj = document.getElementById("mainTable");
var xhtd = document.createElement("td");
with(xhtd){align="center";}
xhtd.innerHTML = tableObj.childNodes[0].childNodes.length;
var xmtd = document.createElement("td");
with(xmtd){align="center";}
xmtd.innerHTML = "<input style="border:0" mce_style="border:0" type='text'><img src="search.jpg" mce_src="search.jpg" onclick='editXm(" + tableObj.childNodes[0].childNodes.length + ")'>";
var rygxtd = document.createElement("td");
with(rygxtd){align="center";}
rygxtd.innerHTML = "<select><option value='1'>父亲</option><option value='2'>母亲</option></select>";
var sctd = document.createElement("td");
with(sctd){align="center";}
sctd.innerHTML = "<img src="delete.jpg" mce_src="delete.jpg" onclick='delTr(" + tableObj.childNodes[0].childNodes.length + ")'>";
var tr = document.createElement("tr");
tr.appendChild(xhtd);
tr.appendChild(xmtd);
tr.appendChild(rygxtd);
tr.appendChild(sctd);
var tableObj = document.getElementById("mainTable");
tableObj.childNodes[0].appendChild(tr);
}
//删除指定行
function delTr(num){
if(window.confirm("真的删除吗?")){
var tableObj = document.getElementById("mainTable");
tableObj.childNodes[0].removeChild(tableObj.childNodes[0].childNodes[num]);
resetSeq();
}
}
//行序列号重置
function resetSeq(){
var tableObj = document.getElementById("mainTable");
for(var i = 1;i < tableObj.rows.length;i ++){
tableObj.rows[i].cells[0].innerHTML = i;
}
}
//模态传值
function editXm(num) {
var tableObj = document.getElementById("mainTable");
var obj = new Object();
obj.name = "title";
var rev = window.showModalDialog("modal.html",obj,'dialogWidth=600px;dialogHeight=600px,dialogLeft=200px,dialogTop=200px,center=yes,help=1,resizable=0,status=1,scroll=1,edge=sunken,unadorned=yes,dialogHide=0');
if(rev){
tableObj.rows[num].cells[1].innerHTML = "<input value='" + rev + "' style="border:0" mce_style="border:0" type='text'><img src="search.jpg" mce_src="search.jpg" onclick='editXm(" + num + ")'>";
}
}