Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

conditional or js to detect whether user is on windows XP?

Because windows xp renders certain fonts so poorly, i would like to detect whether the user is using that OS and add a class to the body accordingly.

I'm looking ideally for an html conditional statement or php $_SERVER var to do this

However failing that a piece of javscript along the lines of below would do

if(users_os === 'xp'){
    $('body').addClass('xp');
}

What avenues should i be persuing?!!!

thanks!


EDIT: TO CLARIFY!

This is further development on a project which renders the webapp in nicer fonts if the user has it natively installed - see part of my solution here: for extending font stacks abilities.

Fonts render differently on combinations of OS and Browser, not Browser alone - i want to be able to know whether a user is on xp or not becuase it's rendering of Calibri is so very poor

like image 780
Haroldo Avatar asked Jun 18 '10 07:06

Haroldo


2 Answers

It actually makes no sense to determine which operating system is used for a Web Application. The only thing which should be of interest, is the Browser. Even in the Browser you just have to care about what it supports and what not.

In JQuery you may use the .support(), .browser() and .boxModel() methods for that purpose.

like image 159
jAndy Avatar answered Oct 25 '22 21:10

jAndy


I fully agree with jAndy's answer, you shouldn't ever need OS detection for a web application and you should rarely need browser detection (the exception being stats/analytics, of course).

That being said, if you're insistent you need this, you can get what you need to know using the PHP function get_browser():

$browser = get_browser();
echo $browser["platform"];
// -> "WinXP"
like image 22
Andy E Avatar answered Oct 25 '22 20:10

Andy E