当点击编辑时打开一个window窗口,现在想完成编辑之后,提交数据,当点击关闭或者直接关闭窗口的时候实现父页面的刷新,现在当点击关闭按钮的时候刷新已经实现,还没有实现的关闭窗口的时候的刷新
<body  onbeforeunload="Exit()">
function Exit()
 {
  if (event.clientX > document.body.clientWidth && event.clientY < 0||event.altkey){
   window.opener.location.reload();
  } 
 }
怎么实现不了,希望各位能帮忙解决一下,下面是我的代码:
<script>
function back() { window.close();
window.opener.location.reload();
//window.opener.location.href=window.opener.location.href;
}
function Exit()
 {
  if (event.clientX > document.body.clientWidth && event.clientY < 0||event.altkey){
   window.opener.location.reload();
  } 
 }
</script>
<%
String appid = CString.getAttribute(request, "appid");
String appname = request.getParameter("appname");
String memo = request.getParameter("memo");
if ("true".equals(request.getParameter("operate"))) {
Connection con1 = null;
Statement sm = null;
DBPoolConnection DBpc = null;
try {
String sql = "update appinfo set appname='" + appname
+ "',memo='" + memo + "'  where appid='" + appid
+ "'";
DBpc = DBPoolConnection.getInstance();
con1 = DBpc.getConnection();
sm = con1.createStatement();
sm.executeUpdate(sql);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (sm != null) {
try {
sm.close();
} catch (SQLException e) {
}
}
if (con1 != null) {
try {
con1.close();
} catch (SQLException e) {
}
}
}
}
%>
<body  onbeforeunload="Exit()">
<form name="form1" action="editapp.jsp" method=post>
<fieldset>
<legend>
<b>编辑APP</b>&nbsp;&nbsp;
</legend>
<table border="0"
style="border-collapse: collapse; margin-left: 10px;"
bordercolor="#808080" cellpadding="0" width="100%">
<tr>
<td>
&nbsp;&nbsp;
</td>
</tr>
<tr>
<td>
&nbsp;&nbsp;
</td>
</tr>
<tr>
<td>
AppID:
</td>
<td>
<input class="txtcss" name="appid"
value="<%=CString.isNull(appid)%>" readonly type="text">
<font color="#FF0000">*</font>
</td>
</tr>
<tr>
<td>
&nbsp;&nbsp;
</td>
</tr>
<tr>
<td>
App名称:
</td>
<td>
<input class="txtcss" name="appname" value="<%=CString.isNull(appname)%>">
<font color="#FF0000">*</font>
</td>
</tr>
<tr>
<td>
&nbsp;&nbsp;
</td>
</tr>
<tr>
<td>
备注:
</td>
<td>
<input class="txtcss" name="memo" value="<%=CString.isNull(memo)%>">
<font color="#FF0000">*</font>
</td>
</tr>
<tr>
<td>
&nbsp;&nbsp;
</td>
</tr>
<tr>
<td>
&nbsp;&nbsp;
</td>
</tr>
<tr>
<td>
&nbsp;&nbsp;
</td>
</tr>
</table>
</fieldset>
<div align="center">
<table>
<tr>
<td align="left" colspan="2">
<input type="submit" class="bt1css" value="提交" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="reset" class="bt1css" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="button" class="bt1css" onClick="back()" value="关闭" />
<input type="hidden" name="operate" value="true" id="operate" />
</td>
</tr>
</table>
</div>
</form>
</body>

解决方案 »

  1.   

    self.opener.location.reload();js让父页面刷新
      

  2.   

    此处window和self都可以实现父页面刷新,然后我把代码写成这样
    function Exit()
     {
      if (event.clientX > document.body.clientWidth && event.clientY < 0||event.altkey){
       alert("success");
       self.opener.location.reload();
      } 
     }
    当关闭窗口的时候,success并没有出来
      

  3.   

    if(event.clientX>document.body.clientWidth&&event.clientY<0||event.altKey||event.ctrlKey)
    应该是 event.clientX>document.body.clientWidth&&event.clientY<0 这句的问题。你可以浏览器调试看看。你也可以
    用onUnload方法  
    在body 标签里加入onUnload事件  
    body onUnload="myClose()"  
    然后在javascript里定义myClose()方法,onUnload方法是在关闭窗口之后执行。
      

  4.   

    页面调试也没出现什么错误,不过根据你的提示,我直接在body标签里的 onUnload="self.opener.location.reload()",这样在提交和关闭的时候都实现了刷新父页面,也就不用考虑关闭浏览器不能刷新那种情况了,不过刚才我的那个问题还是挺纠结,不知道问题出在哪,总之非常感谢