html页面,有的时候不是直接一个页面,一连串(或并行)页面的结束,为了提高用户体验或完成某种功能需要父子页面(或窗口)来实现,或者父子,兄弟窗口来完成。本文主要介绍:
html父子页面(弹框)的实现和交互[通信]
实现简单业务介绍:
1.父页面,点下“注册”按钮,按钮锁定,并弹框;
2.父页面隐藏域的值“欢迎您的注册……”,传给子弹框,并显示;
3.子窗口,进行注册用户,成功后调用父页面js方法,将注册的“用户名”填写到登录用户名中;
4.用户登录,后台ajax传值,显示注册的“用户名”;
5.后台类的处理,使用MAP保存[内存暂时],然后用用户名去获取对象进行登录验证。
父页面jsp代码[popupmain.jsp]:
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>注册页面</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript" src="${pageContext.request.contextPath }/tsjs/jquery-1.11.1.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/tsjs/popupmain.js"></script>
</head>
<body>
<center id="centerid">
<div id="userlogin">
<form id="userloginform">
<table id="tbuserlogin" width="150" border="0" cellpadding="0" cellspacing="0">
<tr class="setshow">
<td width="30">user:</td>
<td width="70">
<input id="userlog" name="userlog" type="text" maxlength="8" size="15" />
</td>
<td width="50"><div id="userlogmsg"></div></td>
</tr>
<tr class="setshow">
<td width="30">pass:</td>
<td width="70">
<input id="passlog" name="passlog" type="password" maxlength="12" size="15" />
</td>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="2" align="right">
<div id="userregbtdiv">
<input type="button" id="popupbt" value="注册" />
</div>
<div id="userloginbtdiv">
<input type="button" id="userlogin" value="登录" οnc