8 replies [Last post]
inababes
inababes's picture
Offline
Regular
Last seen: 19 years 33 weeks ago
Joined: 2003-08-02
Posts: 17
Points: 0

it's been a while since i've tinkered with my website, so i forgot where i got the javascript stylesheet switcher i'm using. it seems to work, but not completely. when you click either the dandelion or sweets link underneath the stylin' chameleon part, the look of the site changes accordingly. BUT the positions of the columns and stuff do not, they retain their old positions according to the previous CSS. and then when i click disable styles using the Web Developer extension on Firefox, suddenly everything renders correctly.

the way i see it, it somehow retains the positioning attributes from the previous stylesheet, yet the colors and images and stuff change properly. why that happens and how to fix it, i have no idea how. help, CSS gurus out there!

Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 1 day 16 hours ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5344
Points: 2965

stylesheet switching

Hi inababes,
Here's an artical from a list apart on style switching that might be helpful.
http://www.alistapart.com/articles/n4switch/

If not provide a link and we can have a look at whats wrong.

inababes
inababes's picture
Offline
Regular
Last seen: 19 years 33 weeks ago
Joined: 2003-08-02
Posts: 17
Points: 0

stylesheet switching

a link, oh yeah a link! i knew i was forgetting something. :? hehe.

http://inababes.neominds.net

that's my site. i probly got the stylesheet switcher from a previous ALA article or something, the one you linked to doesn't look all that familiar.

[edit] i found the ALA article i was referring to. i'm using the styleswitcher.js file from there.

Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 1 day 16 hours ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5344
Points: 2965

stylesheet switching

Hi inababes,
It's working fine for me in Firefox.
Has anyone else been having trouble?

inababes
inababes's picture
Offline
Regular
Last seen: 19 years 33 weeks ago
Joined: 2003-08-02
Posts: 17
Points: 0

stylesheet switching

It is? I'm using Firefox, too. Most of it changes, but not the positioning. Like when you click on "sweets", the background is supposed to be all black, but its not. If you have the webdeveloper extension installed, try clicking disable styles, and then you'll see it as it's supposed to be seen.

it doesn't seem to work in IE either. *sigh*

Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 1 day 16 hours ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5344
Points: 2965

stylesheet switching

Well I really thought you had lost it for a while Smile
Now after disabling styles I can see what your talking about.
I'm not sure whats causing the problem but will look into it.

Feral
Offline
newbie
Last seen: 19 years 4 weeks ago
Joined: 2004-02-24
Posts: 1
Points: 0

stylesheet switching

Not sure how much help this will be (havent looked at the ALA code), but the js function I use for style switching is:

function css(cssName) {

var i;

        for ( i = 0; i < document.styleSheets.length; i++ ) {
          if ( document.styleSheets[i].title == cssName ) {
            document.styleSheets[i].disabled = false;
          }
          else document.styleSheets[i].disabled = true;
        }
}

inababes
inababes's picture
Offline
Regular
Last seen: 19 years 33 weeks ago
Joined: 2003-08-02
Posts: 17
Points: 0

stylesheet switching

oh my goodness i think i've got it.

i went through that article again s-l-o-w-l-y now, trying to catch what i might have missed. and then it hit me smack in the face, just the headings should have clued me in on what was wrong. persistent and preferred. my stylesheet was being persistent in showing up even when i chose alternate stylesheets, i should have made it just preferred. fixing it was as easy as adding a title attribute to the link to the stylesheet. :mrgreen:

now, i could be wrong, or just overly excited, so i'd appreciate it if you could double check to see if it's not just on my browser that it's working properly.

[edit] damnit, i thought i had it. sometimes it seems to load up *without* any stylesheet whatsover. i tried the <style>@import method of importing the default stylesheet, but it made it persistent again.

*pulls hair out in frustration*

inababes
inababes's picture
Offline
Regular
Last seen: 19 years 33 weeks ago
Joined: 2003-08-02
Posts: 17
Points: 0

stylesheet switching

just wanted to say that i *hope* i've finally gotten it this time.
i was missing a few #div definitions (even if they were empty anyway) in some of the stylesheets and i renamed the default stylesheet so it wouldn't get confused with one of the options.

does it work in your browser?

i sure hope so. *crosses fingers*