日期:2014-05-16  浏览次数:20299 次

JSP以Window形式打开刷新父页面
前面写了一个一个差不多的操作,可是那种操做很容易误操作。子窗体打开是父窗体还能操作。
现在给大家分享一个同样能把值给给父窗口同时又控制父窗口不能操作。
以window.showModalDialog形式:
要是带了分页和搜索的话必需在前面加上<base target="_self" />,要不然会单独弹出一个页面。那样就失去了意义。
我们先来看看父窗口的代码:
//弹出框操作
function op()
{
var url="${ctx}/objection.do?method=chooseCustomer";
window.showModalDialog(url,window,"dialogHeight=450px;dialogWidth=800px;center=yes;status=no;scroll=no;resizable=yes");
}
经过Action的操作弹出子页面,在父窗口调用这个JS就可以了。
<td width="10%" class="odd">
4S店名称:
</td>
<td width="18%">
 <input type="text" name="fourSName" id="fourSName"
 onclick="op()" readonly="readonly" />
< input type="hidden" name="CCustomerId" id="CCustomerId" value="1" />
</td>
我的代码是单击这个文体框弹出子窗口

下面我们来看看子窗口:
<td width="5%">
<input type="radio" name="CGoodsStrength1" id="CGoodsStrength1"
value="${Strength.CCustomerId }"
onclick="sele('${Strength.CCustomerId }','${Strength.CCustomerName }');" />
</td>
这是子窗口的单选按扭

function sele(id,name){
CGoodsStrengthId = id;
CGoodsStrengthName = name;
}
调用了这个JS方法
在提交子窗口时:
直接可以操作父窗口的东西
<tr >
<td align="right">
<script>
  function ck()
{
var m=window.dialogArguments;
m.document.getElementById("fourSName").value=CGoodsStrengthName;
m.document.getElementById("CCustomerId").value=CGoodsStrengthId;
window.close();

}
</script>
<input onclick="ck();" value=" 提  交 " type="button" />
</td>
</tr>
这样就可以直接操作父窗口的数据,可以刷新父窗口