Jquery FrameSet设置换肤

本文介绍如何使用jQuery在FrameSet中实现不同皮肤的切换,包括CSS文件的链接、JavaScript代码的编写以及如何在不同框架中应用皮肤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

使用Jquery给<FrameSet>换肤,

 

1.在cssBasePage.jsp也link了皮肤css

<link href="<%=path %>/css/${cookie.b2cPlatform.value==null?'jf_blue':
	cookie.b2cPlatform.value}.css" rel="stylesheet" type="text/css"  id="cssfile" />

 

2.frameTop.jsp页切换皮肤的JS代码

	// 设置样式
	function setCssFile(id){
		//switchSkin(id);
		$("#cssfile").attr("href","css/"+ id +".css"); //设置不同皮肤
		try{
			$(window.parent.frames['main'].document).find("#cssfile")
                                    .attr("href","css/"+ id +".css");//给窗体换肤
			$(window.parent.frames['leftFrame'].document).find("#cssfile")
                                    .attr("href","css/"+ id +".css");//给左树换肤
			$(window.parent.frames['midFrame'].document).find("#cssfile")
                                    .attr("href","css/"+ id +".css");//给主窗体换肤
		}catch(e){ }
		$.cookie( "b2cPlatform" ,  id , { path: '/', expires: 10 });//皮肤名称设置的cookie中
	}
</script>

 

3.frameTop.jsp页<body>体内容

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>frame top page</title>
		<%@ include file="/cssBasePage.jsp"%>
         </head>
<body>
<div class="skin">
	<a href="javascript:setCssFile('jf_blue');">
	<img width="15" height="16" alt="grass" src="images/ocean.gif" /></a>
	<a href="javascript:setCssFile('jf_red');">
	<img width="15" height="16" alt="grass" src="images/oyster.gif" /></a>
	<a href="javascript:setCssFile('jf_green');">
	<img width="15" height="16" alt="grass" src="images/grass.gif" /></a>
</div>
</body>
 

4.框架页frameSet

1.<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>  
2.<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">  
3.<html xmlns="http://www.w3.org/1999/xhtml">  
4.    <head>  
5.        <title>跳转页</title>  
6.    </head>  
7.    <frameset cols="*" rows="75,*" style="height: 100%; overflow:hidden;">  
8.        <frame id="head" scrolling="no" marginwidth="0" marginheight="0" src="<%=request.getContextPath() %>/Login_loginTop" name="topFrame" frameborder="0" scrolling="no" noresize="noresize" id="topFrame"/>  
9.        <frameset  cols="185,8,*" id="myFrame" >  
10.            <frame frameborder="0" scrolling="auto" src="<%=request.getContextPath() %>/LeftMenu_leftMenuShow" name="leftFrame" id="leftFrame"/>  
11.            <frame frameborder="0" scrolling="no" noresize="noresize" id="midFrame" name="midFrame" src="<%=request.getContextPath() %>/Login_loginSwitch"/>  
12.            <frame frameborder="0" scrolling="auto" src="<%=request.getContextPath() %>/Login_loginRight" name="main"  id="main"/>  
13.        </frameset>  
14.        <noframes></noframes>  
15.    </frameset>  
16.</html>  
 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值