Is there a way to detect a Operating system using JQuery or CSS? With CSS I'm referring to something similar to <![if !IE]>
I need to use a specific font only when web page is viewed using Linux and don't want to include this with other os's
examine navigator.userAgent
You can generally find what you seek with simple rx but to do so will require a basic understanding of sniffing. You can find a good example here.
NOTE: i am not suggesting that you use a sniffing library, just that you familiarize yourself with what you need to look for.
As far as dynamically controlling fonts by OS, I think that, barring some edge case that is not stated in your question, simply defining a font stack is your best bet.
Though not directly answering the question of "detecting O/S", you may be able to achieve the desired effect of selecting a font using the font-family
CSS property.
This property lets you chose a list of fonts, where the browser will try to match fonts available on the system. It reads left-to-right and will use the first font available:
body
{
font-family: "Calibri", "Arial", "Sans Serif"
}
In this case, if the "Calibri" font is not available, the system will use "Arial". If "Arial" cannot be found, it will use any available fonts from in the "Sans Serif" family.
With this you can specify your Linux-specific font first and know that other platforms without the font available will display using a suitable font too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With