Forum Moderators: not2easy

Message Too Old, No Replies

IE Stylesheet - when does it get "applied"?

         

theenglishguy

8:06 pm on Dec 29, 2005 (gmt 0)

10+ Year Member



Hello,

I am writing an application that switches a <body>'s class out on an anchor's onclick. It works perfectly in FF, applying the correct styling as I planned it to.

The problem is IE; even though the <body>'s class appears to be correct, the stylesheet's styling doesn't seem to get applied "on the fly" so to speak. Do I need to do anything special to get IE to "re-apply" the stylesheet?

Thanks,
theenglishguy

coopersita

9:44 pm on Dec 29, 2005 (gmt 0)

10+ Year Member



Is it javascript?

It the change in class is to just change a couple of rules in the body, you may want to apply them directly on the change:

<body style="rules here">

Another thing you can do is alert the changes that are supposed to hapen (like alert(document.body.style.color)).

theenglishguy

10:07 pm on Dec 29, 2005 (gmt 0)

10+ Year Member



The onclick event is elsewhere in the page (WordPress, in the sidebar). I use a small javascript to achieve the <body> class switching.

I have a lot of alerts in place, and it appears to be applying the class. What isn't happening is the stylesheet applying its styling.

I.e., I start out with <body class="one"> which has this css:
.one #columns {
background-color: grey;
}

I change it to class="two" via javascript, which has this corresponding css:
.two #columns {
background-color: blue;
}

But it never gets applied.

coopersita

2:17 am on Dec 30, 2005 (gmt 0)

10+ Year Member



I had a similar problem and the way I solved it was to do the switching directly:

<td style="background-color:gray">

I think the problem is that you'd need to refresh the page for the change to actually take place.

A better option yet is to use a styleswitcher. You can do that with php, or javascript.

Go to A List Apart and look for the article "Invasion of the Body Switchers" by Andy Clarke, James Edwards for a Javascript styleswitcher, or "Build a PHP Switcher"
by Chris Clark for a PHP one.

theenglishguy

12:40 am on Dec 31, 2005 (gmt 0)

10+ Year Member



That did it, thank you! Got it fixed :)