公共父页面(主页面):

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
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>My JSP 'test.jsp' starting page</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">
--> </head> <body>
<input id="test"/>
<iframe id="iframe1" src="a.jsp"></iframe>
<iframe id="iframe2" src="b.jsp"></iframe>
</body>
</html>

a页面:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
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>My JSP 'a.jsp' starting page</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="js/jquery-1.9.1.min.js"></script>
</head> <body>
a页面 <script type="text/javascript">
$(function(){
var x = window.parent.document.getElementById("iframe2");
var right = (x.contentWindow || x.contentDocument);
if(right.document){
right = right.document;
}
alert(right.getElementById("testId").value);
})
</script>
</body>
</html>

b页面:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
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>My JSP 'b.jsp' starting page</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="js/jquery-1.9.1.min.js"></script>
</head> <body>
b页面
<input id="testId" type="text" value="我是b页面啊"/> <script type="text/javascript">
$(function(){
var testVal = $("#testId").val();
window.parent.document.getElementById("test").value = testVal;
})
</script>
</body>
</html>

效果图:

1、页面刚加载时(a页面获取到b页面文本框内的值):

2、页面加载完毕后(将b页面文本框的值赋值给父页面)

最新文章

  1. 采用MVC模式JDBC演示案例
  2. linux下服务端实现公网数据转发
  3. FatMouse&#39; Trade_贪心
  4. Fedora 21 install chrome
  5. csuoj 1335: 高桥和低桥
  6. C# 阳历转农历
  7. Aborting a running program
  8. Tomcat线程池,更符合大家想象的可扩展线程池
  9. 【转】OCR识别引擎tesseract使用方法——安装leptonica和libtiff
  10. 鸟哥linux私房菜学习笔记,U盘安装centos5.3不能正常引导的问题
  11. Java反射-中级知识掌握
  12. kubernetes 手绘画,先收藏一下
  13. linux下ruby使用tcl/tk编程环境设置
  14. http stream
  15. Java中关于CyclicBarrier的使用
  16. HTML DOM 学习笔记
  17. 增加swap分区,文件形式
  18. python 内置函数enumerate()
  19. js样式之渐变线
  20. 转:javascript获取上一访问页面

热门文章

  1. 详谈 Spring 中的 IOC 和 AOP
  2. Java还是程序员的金饭碗
  3. Revit二次开发示例:DeleteDimensions
  4. python学习笔记 - for循环: 遍历字典, 分别打印key, value, key:value
  5. 使用SoapUI测试windows身份验证的webservice
  6. BZOJ.2460.[BeiJing2011]元素(线性基 贪心)
  7. [POI2015]Pieczęć
  8. Codeforces Round #361 (Div. 2) C. Mike and Chocolate Thieves 二分
  9. Codeforces Round #296 (Div. 1) B. Clique Problem 贪心
  10. jQuery和$、jQuery(function(){})和(function(){})(jQuery)