Last active
          November 3, 2019 09:10 
        
      - 
      
- 
        Save ivo-ivanov/d5a3f5153e9790344e75fbc95930b70f to your computer and use it in GitHub Desktop. 
    Detecting Operating System with Javascript #javascript #jquery
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // Detect OS and set body class | |
| var OSName="os-unknown"; | |
| if (navigator.appVersion.indexOf("Win")!=-1) OSName="os-windows"; | |
| else if (navigator.appVersion.indexOf("Mac")!=-1) OSName="os-mac"; | |
| else if (navigator.appVersion.indexOf("X11")!=-1) OSName="os-unix"; | |
| else if (navigator.appVersion.indexOf("Linux")!=-1) OSName="os-linux"; | |
| $('body').addClass(OSName); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment