Jquery给frameset换肤,cookie动态加载css

frameSet页面:

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

topFrame页面:

<%@ 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"%>
<script type="text/javascript">
	// 设置样式
	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 });
	}
</script>
	</head>

	<body  style="height: 100%; overflow:hidden;">
		<div class="jf_top">
			<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>
			
		</div>
	</body>
</html>

需要换肤的页面引入:

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

默认为jf_blue.css.
操作cookie引用了jquery.cookie.js。

 


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值