0

I'm trying to make a 'css hack' that will allow me to change css depending on a user's OS.

For Mac and iOS I want one style, for everything else (Windows, Linux, Android, etc...) I want a different style.

So far I've cobbled together this:

if (navigator.platform = :not("MacIntel")) {
        $("p").css("font-size", "50px");
    } 

But, I'm not sure how to take it further.

What I want to do is say: if not Mac or iOS, then change the css font size element.

Any idea how i can do this?

I've made a jsFiddle here:

As I've said above, I've got it half working... I need help getting it to 100%.

Thanks!

jahroy
  • 22,322
  • 9
  • 59
  • 108
sam
  • 9,486
  • 36
  • 109
  • 160
  • Have a look here: http://www.quirksmode.org/js/detect.html – Amy Mar 14 '13 at 23:01
  • 3
    There are literally thousands of user agent strings, using it to determine the OS means you will get it wrong at least some of the time (for starters, a good percentage of devices running Mac OS don't use Intel chips). If you explain what you are trying to do, you will likely get an alternative solution that is more suitable, probably based on CSS and not requiring any script at all. – RobG Mar 14 '13 at 23:43
  • 1
    @RobG - ok, what im trying to do is im using a very fine font-weight, i can get it to render well on mac all browsers, but for all others including ios i need to up the font-weight, but from a visual point of view the lower font weight is nicer, so if i can id like to use it (ie use it on mac in all browsers), if not id use the thicker font (ie use it in all os that arnt osx, again on all browsers) – sam Mar 15 '13 at 00:00
  • I can identify with this issue... It sure would be nice if Windows could render fonts as well as Mac OS X. – jahroy Mar 15 '13 at 00:05
  • Searching this site leads me to [this plugin](http://www.stoimen.com/blog/2009/07/16/jquery-browser-and-os-detection-plugin/). I won't bother with the token "_feature detection is better_" rant... – jahroy Mar 15 '13 at 00:08
  • 1
    @Sam—if your fonts are that fine, then likely many Mac users don't want them that small either. There are fundamental differences in how Windows and Mac OS render text—Mac goes for accuracy at the expense of prettiness (though with modern high resolution screens, that is now overcome), whereas Windows goes for "looks good" at the expense of accuracy. You wont overcome that by messing with font size based on OS. BTW, I use both OSs about the same every day and yes, fonts on Mac OS look very much better than on Windows. But it wasn't like that when we had 72dpi monitors. :-) – RobG Mar 15 '13 at 02:21

1 Answers1

0

Saw something here:How to detect mobile browser using jQuery or in some other SIMPLE way..?

var android = (navigator.platform.indexOf("android")>=0); //true if android
Community
  • 1
  • 1
tymeJV
  • 103,943
  • 14
  • 161
  • 157