View Full Version : [DHTML] Old Internet Explorer, Different Stylesheet

11-23-2007, 11:08 AM
1) CODE TITLE: Old Internet Explorer, Different Stylesheet


3) DESCRIPTION: Internet Explorer 6 and below dont support the position: fixed; attribute in CSS. Therefore if you use the attribute it will really mess up your design.

So this script detects if you use Internet Explorer 6 or below and then attatches a different stylesheet.

In any other case (Opera, Safari etc.) it just loads the normal stylesheet.

11-23-2007, 12:00 PM
Browser detection is bad (and, done like this, inaccurate). If you need to do this, use conditional comments:
<!-- [if IE < 7]>
<link type="text/css" rel="stylesheet" src="ie.css">
<!--[if !IE]>-->
<link type="text/css" rel="stylesheet" src="other.css">

11-29-2007, 08:10 PM
Your text file doesn't make clear whether you know how to emulate 'position: fixed' in IE<7.
Using the underscore hack, you could have something like the following for a fixed position on top in all browsers:
<div style="position:fixed;left:0;width:100%;height:35px;background:white;top:0px; padding:2px;_position:absolute;_top:expression(eval(document.compatMode && document.compatMode=='CSS1Compat') ? documentElement.scrollTop+screen.height*0 : document.body.scrollTop+screen.height*0)"></div>

But we don't like hacking, so we could use the above coding in conditional statements (without the underscores), as suggested by Twey.

Important: just to make sure that there is no 'trembling' of the fixed div in IE when you scroll down, the body should be styled as:
body{background:url(foo) fixed;}

Arie Molendijk.