Welcome Guest, Not a member yet? Register   Sign In
CSS color scheme switching
#12

[eluser]xwero[/eluser]
Code:
$(function(){
  if($.cookie('csstheme') != null && $.cookie('csstheme') != '')
  {
    $('link[@title=themecss]').attr('href','theme_'+$.cookie('csstheme')+'.css');
  }
  $('a').click(function() {
   var baseurl = $('link[@title=themecss]').attr('href');
   baseurl = baseurl.substr(0,baseurl.lastIndexOf('/')+1);
   $.cookie('csstheme', $(this).text());
   $('link[@title=themecss]').attr('href','theme_'+$(this).text()+'.css');
});
});
This works for me on FF and IE7
I'm using the cookie plugin.

ps : no page refresh needed Wink

update : html
Code:
<html>
<head>
<title>jQuery stylesheet switcher</title>
<script src="jquery-1.2.1.min.js"></script>
<script src="jquery.cookie.js"></script>
<script src="jquery.own.js"></script>
<link rel="stylesheet" type="text/css" title="themecss" href="theme_blue.css" />
</head>
<body>
<h1>I change color</h1>
<a href="#">red</a>
<a href="#">orange</a>
<a href="#">green</a>
&lt;/body&gt;
&lt;/html&gt;


Messages In This Thread
CSS color scheme switching - by El Forum - 10-27-2007, 03:12 AM
CSS color scheme switching - by El Forum - 10-27-2007, 06:20 AM
CSS color scheme switching - by El Forum - 10-27-2007, 06:41 AM
CSS color scheme switching - by El Forum - 10-27-2007, 07:29 AM
CSS color scheme switching - by El Forum - 10-27-2007, 08:36 AM
CSS color scheme switching - by El Forum - 10-27-2007, 09:33 AM
CSS color scheme switching - by El Forum - 10-27-2007, 10:00 AM
CSS color scheme switching - by El Forum - 10-27-2007, 10:50 AM
CSS color scheme switching - by El Forum - 10-28-2007, 09:41 AM
CSS color scheme switching - by El Forum - 10-28-2007, 11:39 PM
CSS color scheme switching - by El Forum - 10-29-2007, 02:06 AM
CSS color scheme switching - by El Forum - 10-30-2007, 01:17 AM
CSS color scheme switching - by El Forum - 10-30-2007, 11:42 PM
CSS color scheme switching - by El Forum - 10-31-2007, 07:55 AM



Theme © iAndrew 2016 - Forum software by © MyBB