mengu on web programming.

jQuery OS Detection

Windows doesn't have Lucida Grande font by default so my visitors from Windows was reading my posts with the default browser font. I wanted to change the font-family property for Windows users from Lucida Grande to Lucida Sans Unicode. I have searched and found a plugin to detect client's operating system with jQuery. Many thanks go to [Stoimen](http://www.stoimen.com/blog/) for this plugin. You can download the plugin [here](http://www.stoimen.com/blog/2009/07/16/jquery-browser-and-os-detection-plugin/) and you can see the plugin in action [here](http://stoimen.com/jquery.client.plugin/). Usage of the plugin is very simple. $.client.os returns the client's operating system and $.client.browser returns the client's browser. How I used this plugin is also very simple: $(document).ready(function(){ if ($.client.os == "Windows") { $(".post").css('font-family', 'Lucida Sans Unicode, sans-serif'); } }); Again, I'd like to thank Stoimen for this plugin.
Check my latest project compector.com where you can post references about your former employers and see what others have said about the future employers. Sign up now and post a reference and share it on twitter or facebook.

Comments

meo said on 16/09/2010 18:42 PM
This is the total overkill, just use fallback fonts in CSS... font-family: 'Lucida Grande', 'Lucida Sans Unicode, sans-serif etc...

Mengu Kagan said on 17/09/2010 21:00 PM
now i have just learnt something new! thanks meo! :)

SinisterMinister said on 10/11/2010 04:08 AM
@meo - It's not overkill at all. For instance, one of my sites uses Avenir for the font, but it only looks good on a Mac (due to different font rendering algorithms between OS X and Windows). So, on Windows, I needed to chose a different font. If you don't believe me, [take a look](http://www.sinimini.com/media/images/ss.png).

Mengu Kagan said on 17/11/2010 16:04 PM
now i'm glad that did work out for someone else too. :) good luck with the site SinisterMinister.

it shows an error like $.client.os is not a function said on 26/11/2010 12:24 PM
please send me the solution for recognizing the os through jquery and normal java script

rafael said on 19/05/2011 17:52 PM
i see the fix for detecting browser VERSIONS. do you know of a fix for OS versions?

rafael da costa said on 19/05/2011 18:57 PM
can the script be updated to detect Android os and browser versions?

Leave a Response

No HTML allowed. You can use markdown.
Name*:
E-Mail* (not published):
Web site:
Response: