子窗口提交后关闭,父窗口刷新

父窗口页面
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
request.setAttribute("path",path);
request.setAttribute("basePath",basePath);
%><html>
<head>
<!--aa.jsp-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Pragma" CONTENT="no-cache">
<meta http-equiv="Cache-Control" CONTENT="no-cache">
<meta http-equiv="Expires" CONTENT="-1">
<title>父窗口</title>
<link href="${path}/css/common.css" rel=stylesheet type="text/css">
<link href="${path}/css/table.css" rel=stylesheet type="text/css">
<link href="${path}/css/content.css" rel=stylesheet type="text/css">
<script language="javascript">
function gotoPage(butType)

var src = "";
switch(type)
{  
case "search":
src= "${path}yy.do?条件";
break;
case "add":
//弹出父窗口,如果子窗口需要url,则url在此是实际的获得数据的路径     
var winFrame=window.showModalDialog("bb.jsp", "winFrame", 'dialogWidth:500px;  dialogHeight:300px; center:yes; resizable:no;  status:no; help:no;');
//判断从子窗口返回值,如果是1,刷新父窗口(重新提交)
if(winFrame==1){
//重新提交(也就是重新加载数据列表)
src= "${path}yy.do?条件";
$("framePage").src = src;
}
break;
}
$("framePage").src = src;
}
</script>
</head>

<body id="content_body" scroll="no" >
<form>
<table width="100%" height="100%"  border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="3" align="left" valign="middle">

<table width="900" height="24"  cellpadding="0" cellspacing="0" onDblClick="hideSearchPanel();" id="tool_bar">
                <tr>
   <td>
      <input type="button" name="检索" value="检索数据" onClick="gotoPage('search')"/>
   </td>
</tr>
    <tr>
   <td>
      <!--数据列表-->
   </td>
</tr>
<tr>
<td width="5"></td>
    <td >
       <input type="button" name="button" value="弹出子窗口" onClick="gotoPage('add');" style="width: 80px;"/>
    </td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center" valign="middle" >
<iframe id="framePage" name="framePage" src="${path}yy.do"  height="100%" width="100%" scrolling="auto" frameborder="1" border="1">
</td>
</tr>
</table>     
</form>
</body>
</html>

子窗口页面
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
request.setAttribute("path",path);
request.setAttribute("basePath",basePath);
%>
<html>
<head>
<!--bb.jsp子窗口-->
<!--base 和title是必须的,而且必须放在这个位置-->
<base target="_self">
<title>子窗口名称</title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Pragma" CONTENT="no-cache">
<meta http-equiv="Cache-Control" CONTENT="no-cache">
<meta http-equiv="Expires" CONTENT="-1">
<script type="text/javascript" src="${path}/js/jquery-1.4.2.min.js"></script>
<script language="javascript">

function add(){ 
   src="${path}xxx.do";
  //在此的action路径,返回页面为本身页面
   frm.action=src;
   frm.submit();
   //提交完毕关闭本身页面
   window.close();
}
</script>
</head>

<body>
<script>
    //向父窗口返回一个标志,在父窗口判断,如果为1就刷新
    window.returnValue=1;
</script>
<form action="" name="frm" id="frm">
<table width="100%" height="100%"  border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td>
      <input type="button" name="button" value="添加数据" onClick="add();"/>
    </td>
  </tr>
</table>
</form>
</body>
</html>

你可能感兴趣的:(html,jsp,struts,sun)