frameset布局

inc.jsp:

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
request.setAttribute("basePath",basePath);
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'inc.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">
	<script type="text/javascript" src="${basePath}/js/jquery-1.8.2.js"></script>
	<script type="text/javascript">
		var jspath=getRootPath();
		//获取项目根路径
		function getRootPath(){
		    //获取当前网址,如: http://localhost:8083/uimcardprj/share/meun.jsp
		    var curWwwPath=window.document.location.href;
		    //获取主机地址之后的目录,如: uimcardprj/share/meun.jsp
		    var pathName=window.document.location.pathname;
		    var pos=curWwwPath.indexOf(pathName);
		    //获取主机地址,如: http://localhost:8083
		    var localhostPaht=curWwwPath.substring(0,pos);
		    //获取带"/"的项目名,如:/uimcardprj
		    var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
		    return(localhostPaht+projectName);
		}

	</script>

  </head>
</html>

 

index.jsp:

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<jsp:include page="../layout/inc.jsp" /> 
<%
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">
	<script type="text/javascript">
		function doMenu(param){
			var iframe=document.getElementById("centerframe");
			if(param==1){
				iframe.src=jspath+"/layout/a1.jsp";
			}else if(param==2){
				iframe.src=jspath+"/layout/a2.jsp";
			}
		}
	</script>

  </head>
  
    <frameset rows="50,*,40">
       <frame id="topframe" name="topframe" src="${basePath}/layout/top.jsp">
       <frame id="centerframe" name="centerframe" src="${basePath}/layout/center.jsp">
       <frame id="bottomframe" name="bottomframe" src="${basePath}/layout/bottom.jsp">
 	</frameset>
</html>

 

center.jsp:

<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
<jsp:include page="../layout/inc.jsp" /> 
<%
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 'center.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">
	<script type="text/javascript">
		//链接
		function doLink(param){
			var iframe=document.getElementById("mainframe");
			$.ajax({               
                type: "POST",               
                dataType: "json",               
                url: jspath+param,   
                success: function(data) {   
                    alert(data);
                    iframe.src=jspath+data;
                }   
            });  
		}
	</script>
  </head>
   <frameset cols="30%,70%">
   		<frame id="leftframe" name="leftframe" src="${basePath}/layout/left.jsp">
   		<frame id="mainframe" name="mainframe" src="${basePath}/layout/main.jsp">
   </frameset>
</html>

 

/**
	 * @author chenzheng
	 * @since 2013-8-25
	 * @Description: 链接一
	 * @throws
	 * @return
	 * @throws Exception
	 * String
	 */
	public String doLink1Action() throws Exception {
		HttpServletResponse response = ServletActionContext.getResponse();
		response.setCharacterEncoding("utf-8");
		PrintWriter pw = null;
		try {
			pw = response.getWriter();
			pw.write("/layout/a1.jsp");
		} catch (IOException e) {
			e.printStackTrace();
		}
		pw.flush();
		pw.close();
		return null;
	}
	
	/**
	 * @author chenzheng
	 * @since 2013-8-25
	 * @Description: 链接二
	 * @throws
	 * @return
	 * @throws Exception
	 * String
	 */
	public String doLink2Action() throws Exception {
		HttpServletResponse response = ServletActionContext.getResponse();
		response.setCharacterEncoding("utf-8");
		PrintWriter pw = null;
		try {
			pw = response.getWriter();
			pw.write("/layout/a2.jsp");
		} catch (IOException e) {
			e.printStackTrace();
		}
		pw.flush();
		pw.close();
		return null;
	}

 

 效果图:

效果图

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
概述 定义和用法 frameset 元素可定义一个框架集。它被用来组织多个窗口(框架)。每个框架存有独立的文档。在其最简单的应用中,frameset 元素仅仅会规定在框架集中存在多少列或多少行。您必须使用 cols 或 rows 属性。[1] 类别 HTML之中的元素之一。 作用 其作用是指定一个框架集,用于组织多个框架和嵌套框架集。 FRAMESET 元素是 FRAME 元素的容器。HTML 文档可包含 FRAMESET 元素或 BODY 元素之一,而不能同时包含两者。 如果用户在框架中打开了 Web 文件夹后单击了 Web 文件夹中的内容,那么被单击的文件或文件夹将取代整个窗口。例如,假设页面包含两个框架,一个框架指向 http://www.microsoft.com 第二个框架指向网络驱动器。如果用户单击第二个框架中的文件或文件夹,该框架将活动整个窗口的控制,包括第一个框架。对于浏览器不能处理的文件类型,如 *.txt 文件,将会打开对应的应用程序窗口。 尽管 Web 文件夹是文件系统层次的一部分,但是该技术并不总是表示文件系统中的实际内容。一个典型的例子就是网络邻居。 使用范围 此元素在 Microsoft® Internet Explorer 3.0 的 HTML 中可用,在 Internet Explorer 4.0 的脚本中可用。 注意:不能与 <frameset></frameset> 标签一起使用 <body></body> 标签。不过,如果需要为不支持框架的浏览器添加一个 <noframes> 标签,请务必将此标签放置在 <body></body> 标签中! 编辑本段示例 下面的例子使用了 FRAMESET 元素来定义页面中的三列矩形。 <FRAMESET COLS="25%, 50%, *"> <FRAME SRC="contents.htm"> <FRAME SRC="info.htm"> <FRAME SCROLLING="NO" SRC="graphic.htm"> </FRAMESET> COLS="25%,* " 垂直切割画面(如分左右两个画面),接受整数值、百分数, * 则代表占用馀下空 间。数值的个数代表分成的视窗数目且以逗号分隔。例如 COLS="30,* ,50%" 可以切成三个视窗,第一个视窗是 30 pixels 的宽度,为一绝对分割,第二个视窗是当分配完第一及第三个视窗后剩下的空间,第三个视窗则占整个画面的 50% 宽度为一相对分割。您可自己调整数字。 ROWS="120,* " 就是横向切割,将画面上下分开,数值设定同上。唯 COLS 与 ROWS 两参数尽量不要同在一个 <FRAMESET> 标记中,因 Netacape 偶然不能显示这类形的框架,尽量采用多重分割。 <FRAME> 参数设定: 例子:<frame name="top" src="info.html" marginwidth="5" marginheight="5" scrolling="Auto" frameborder="0" noresize framespacing="6" bordercolor="#0000FF"> name="top" 设定这个框窗的名称,这样才能指定框架来作连结,必须但任意命名。 src="info.html" 设定此框窗中要显示的网页档案名称,每个框窗一定要对应着一个网页档案。你可使用绝对路径或相对路径,有关此两者详见於【连结进阶】。 marginwidth=5 表示框架宽度部份边缘所保留的空间。 marginheight=5 表示框架高度部份边缘所保留的空间。 scrolling="Auto" 设定是否要显示卷轴,YES 表示要显示卷轴,NO 表示无论如何都不要显示, AUTO是视情况显示。 frameborder=0 设定框架的边框,其值只有 0 和 1 , 0 表示不要边框, 1 表示要显示边框。(避 免使用 yes 或 no ) framespacing="6" 表示框架与框架间的保留空白的距离。 bordercolor="#008000" 设定框架的边框颜色。颜色值请参考【HTML 剖析】。 另外: border="0" 设定框架的边框厚度,以 pixels 为单位。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值