Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would use the <code>navigator.useragent</code> property to get the useragent-string, parse it, and detect the OS.</p> <p><strike><a href="http://www.quirksmode.org/js/detect.html">Here</a> is one example of how you can do it.</strike></p> <p><strong>Update:</strong></p> <p>Due to the popularity of this question, I thought I would add some additional information to my answer.</p> <p>In general, browser sniffing is almost never the best way to go. Why? Well, there are many reasons, but here are two good ones:</p> <ol> <li>In almost all cases when people turn to browser sniffing, <strong>feature detection would be a better option</strong>. There are rare edge cases where it might be appropriate to act depending on what OS/browser the user might be using, but for the most part, using a library like <a href="http://modernizr.com/">Modernizr</a> to detect support for a specific feature is a better way to go. Trying to adapt your site/application to specific browsers rather than the features they support is a slippery slope. Instead check if the browser support the features you need, and polyfill or provide nice fallbacks when support is lacking.</li> <li><strong>Browser sniffing is extremely complicated</strong>. Why? Because almost every browser lie in their user agent string or lack sufficient information to allow a certain identification.</li> </ol> <p>With that said, if you really really need to use browser/OS detection, then don't reinvent the wheel, and don't try to do it on your own - you will be in for a world of pain and obscure caveats! I would suggest you use a library like <a href="https://github.com/NielsLeenheer/WhichBrowser">WhichBrowser</a>, that will provide you with a handy JavaScript object containing information about the os, browser, rendering engine and device.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload