#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    247
    Rep Power
    12

    CSS - Theme Switch


    Hello all once again.
    Ok, I have been playing about with css and looking around many different sites till I found an article from 'a list apart': Click here to view

    So, Here is the page I want two be able to change: click here

    I have this in the Head :
    <LINK rel="stylesheet" href="green.css" type="text/css">
    <link rel="alternate stylesheet" type="text/css" href="red.css" title="red" />
    <script type="text/javascript" src="/scripts/styleswitcher.js"></script>
    and these are the links in the page:
    <a href="#" onclick="setActiveStyleSheet('green'); return false;">change style to default</a><br />
    <a href="#" onclick="setActiveStyleSheet('red'); return false;">change style to red</a>
    The .js files contains this:
    function setActiveStyleSheet(title) {
    var i, a, main;
    for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
    a.disabled = true;
    if(a.getAttribute("title") == title) a.disabled = false;
    }
    }
    }

    function getActiveStyleSheet() {
    var i, a;
    for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
    }
    return null;
    }

    function getPreferredStyleSheet() {
    var i, a;
    for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
    && a.getAttribute("rel").indexOf("alt") == -1
    && a.getAttribute("title")
    ) return a.getAttribute("title");
    }
    return null;
    }

    function createCookie(name,value,days) {
    if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
    }
    else expires = "";
    document.ignore = name+"="+value+expires+"; path=/";
    }

    function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
    }

    window.onload = function(e) {
    var cookie = readCookie("style");
    var title = cookie ? cookie : getPreferredStyleSheet();
    setActiveStyleSheet(title);
    }

    window.onunload = function(e) {
    var title = getActiveStyleSheet();
    createCookie("style", title, 365);
    }

    var cookie = readCookie("style");
    var title = cookie ? cookie : getPreferredStyleSheet();
    setActiveStyleSheet(title);[/QUOTE]

    So I have it all uploaded but when I try to change to the red theme nothing happens and when I try to open the .js file I get an error. Can someone plz help

    Once again: click here to see the page I am working on.

    Thank you
  2. #2
  3. :(){ :|:&};:
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Germany
    Posts
    297
    Rep Power
    12
    Hmm, which browser are you using?
    Also when I am visiting your site with Firebird, there seems to be a problem with the layers as the links lie over the main banner %)

    There was a thread like easier yesterday, so if you please search for it. Basicly, go to www.w3.org/Style and then Zengarden and you will find very profound help

    Please do some research - if it doesn't work afterwards please post again
    regards >_<

    ws. fgeller.de
    em. felix@fgeller.de
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    247
    Rep Power
    12
    I have done research and have followed the instructions but its still causing an error for me

    I'm using IE, must be that firebird doesn't have enough support for css.

    Anyone able to point out whats causing the problem plz?
  6. #4
  7. :(){ :|:&};:
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Germany
    Posts
    297
    Rep Power
    12
    mpf Firebird has way more css support then any available Internet Explorer. And if you have done some research why can't point out your error messages?
    regards >_<

    ws. fgeller.de
    em. felix@fgeller.de

IMN logo majestic logo threadwatch logo seochat tools logo