JSP以Window形式打开刷新父页面

本文介绍了一种通过window.showModalDialog方法实现子窗口与父窗口交互的技术,该方法能有效防止用户误操作,并允许子窗口更新父窗口的数据。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

前面写了一个一个差不多的操作,可是那种操做很容易误操作。子窗体打开是父窗体还能操作。
现在给大家分享一个同样能把值给给父窗口同时又控制父窗口不能操作。
以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>
这样就可以直接操作父窗口的数据,可以刷新父窗口
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值