Forum Moderators: open

Message Too Old, No Replies

alternate stylesheet not working in ie6 or 7

         

wardy83

5:29 pm on Apr 12, 2007 (gmt 0)

10+ Year Member



Hi, basically I have an alternate stylesheet switcher using javascript, taken from #*$! and it works fine in mozilla, but doesn't in ie6 or ie7... I know why thi is, it's because of the:

<!--[if IE]>
<link rel="stylesheet" type="text/css" href="ie.css" />
<![endif]-->

statement I have in, which is overwriting it.

Is there a way around this?

Dabrowski

5:33 pm on Apr 12, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ummmm, remove above statement?

wardy83

8:44 am on Apr 13, 2007 (gmt 0)

10+ Year Member



Well if I do that the site will look different in internet explorer!

It wouldn't be good practice to make them 'click here' if you have ie!

Dabrowski

9:27 am on Apr 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Oh I see, sorry.

I often use multiple stylesheets, something like mysite.css and then I use a bit of JS to include mysite-ie6.css which contains IE6 specifics.

Are you saying you have everything in one stylesheet so the JS is inserting the correct one, and then that is being overwritten by the 'if IE' bit?

wardy83

3:19 pm on Apr 13, 2007 (gmt 0)

10+ Year Member



yeh thats right, the problem with the sytleswitcher tutorial is it doesn't take into consideration that I have an alternate option for ie browsers, so it always sticks with the ie.css rather than alternate.css when it's clicked.... it's fine in firefox though.

just wondering what the best option (if any) there is or if i should just forget about it :?

Fotiman

4:28 pm on Apr 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Which stylesheet switcher are you using?
PS- I sent you sticky mail.

Dabrowski

4:53 pm on Apr 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The only difference is that I use JS to insert my additional stylesheet, try this:


<!--[if IE]>
<script>
document.writeln( "<link rel='stylesheet' type='text/css' href='ie.css' />");
</script>
<![endif]-->

Also I'm using HTML4.01/strict, not XHTML, but I don't think that would affect it.

SuzyUK

9:56 am on Apr 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



totally unfounded guess but what happens if you import the IE stylesheet rather than linking to it?

<!--[if IE]>
<style type="text/css" media="screen">
@import "ie.css";
</style>
<![endif]-->