Log in

View Full Version : CSS specifically for Windows XP



fase_xi
01-29-2011, 09:14 AM
I want to create a separate stylesheet for users running Windows XP. Is there a way to do it? I just want to assign a different font family to Windows XP users. I have seen codes in which you have different stylesheet for OSX and Windows. But I would like it to be Win XP only. I tried looking around the web but couldn't find anything on it.

djr33
01-29-2011, 02:49 PM
You can check the user agent string to see if it contains windows xp or just xp or some variation. Look for a few examples of such user agent strings then work from there bit won't be completely reliable but this is not a fundamental requirement so it should be ok.

jscheuer1
01-29-2011, 04:03 PM
Bad idea. Why would you want to do this? Like you know how a particular font is gonna look on every machine in the world that's running XP. I think not!

Design your site to look OK in any browser or OS, only use a fudge if absolutely required, and then base it upon a browser's self identified capabilities, not upon some report from the navigator object.

That said, here's a link to a navigator object tool I wrote that will show you what you get:

http://home.comcast.net/~jscheuer1/side/nav_obj/

Everything in the property column can be got as:


navigator.property

So you could do like:


alert(navigator.userAgent);

to get the string. Or (looks like from here this may work):


<script type="text/javascript">
var osVer = /^.*Windows NT (\d\.\d+).*/.exec(navigator.userAgent);
if(osVer && osVer[1] < 6 && osVer[1] > 5.09){
do whatever;
}
</script>

It looks for 'Windows NT #.#' and pulls the number for testing if its there. According to:

http://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx#UATokenRef

Testing the range to be between 5.09 and 6 will get you


Windows Server 2003; Windows XP x64 Edition; Windows XP

all presumably XP or XP-ish.

But - Be aware, the default for XP is Clear Type off, though I would think most folks have turned it on by now. You cannot control or determine this. It will change most any font's appearance. And various browsers will render things differently even on the same XP machine using the same font. And the font you want might not be available on a given XP system and/or given browser on that system.

fase_xi
02-02-2011, 02:32 PM
Thanks. Just found some time to try it. That's pretty much what I was looking for.