frameset父页面和子页面的方法之间调用个属性的调用(页面上可以包含iframe)...

在frameset上可以在页面上面划分出多个区域,这是一般管理系统的主要布局方式,但是再一个页面可以调用另外一个页面的属性和方法。页面上可以包含iframe嵌套。

祖先页面:

<%@ 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 'index.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">
		function top1(){
			alert("祖先方法");
		}
	</script>
  </head>
  
  <frameset cols="50%,50%">
  	<frame src="html/1.html" name="c1"></frame>
  	<frame src="html/2.html" name="c2"></frame>
  </frameset>
</html>

  

儿子1页面 1.html:

<!DOCTYPE html>
<html>
  <head>
    <title>1.html</title>
	
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
    <script type="text/javascript" src="../js/jquery.min.js"></script>
	<script type="text/javascript">
		$().ready(function(){
  			alert("左边加载完...");
  			alert($('span',window.parent.frames["c2"].document).text());
  		});
	
		function xd1(){
			alert("我是左边的方法");
		}
	</script>
  </head>
  
  <body>
    11111111111111111111<p/>
    <button οnclick='window.parent.frames["c2"].xd2();'>调右边的方法</button>
    <button οnclick='window.parent.frames["c2"].frames["c21"].sunzi();'>调右边的儿子方法</button>
  </body>
</html>

 

儿子二页面 2.html:

<!DOCTYPE html>
<html>
  <head>
    <title>2.html</title>
	
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
	<script type="text/javascript" src="../js/jquery.min.js"></script>
	<script type="text/javascript">
		$().ready(function(){
  			alert("右边加载完...");
  		});
	
		function xd2(){
			alert("我是右边的方法");
		}
	</script>
  </head>
  
  <body>
  <span>我是右边的属性</span>
    2222222222222222222222
    <div>
    	<iframe src="3.html" name="c21"></iframe>
    </div>
  </body>
</html>

 

二儿子的儿子页面 3.html:

<!DOCTYPE html>
<html>
  <head>
    <title>3.html</title>
	
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
	<script type="text/javascript">
		function sunzi(){
			alert("孙子方法");
		}
	</script>
  </head>
  
  <body>
    我是页面2的儿子<p/>
    <button οnclick="window.parent.xd2();">父亲按钮</button>
    <button οnclick='window.parent.parent.frames["c1"].xd1();'>爷爷按钮</button>
    <button οnclick="window.top.top1();">祖先按钮</button>
  </body>
</html>

 

frameset是最早的祖先页面。frame是祖先页面的子页面,原理和iframe是一样的。无论其方法调用还是祖父元素和兄弟页面之间调用都和iframe一样的。

 

参考链接:

http://747017186.iteye.com/blog/1985110

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值