How to detect my browser version and operating system using JavaScript?

后端 未结 10 954
天命终不由人
天命终不由人 2020-11-22 06:25

I have tried using the code below but it only display results in Chrome and Mozilla not working in IE6.

10条回答
  •  遇见更好的自我
    2020-11-22 07:26

    There is a library for this purpose: https://github.com/bestiejs/platform.js#readme

    Then you can use it this way

    // example 1
    platform.os; // 'Windows Server 2008 R2 / 7 x64'
    
    // example 2 on an iPad
    platform.os; // 'iOS 5.0'
    
    // you can also access on the browser and some other properties
    platform.name; // 'Safari'
    platform.version; // '5.1'
    platform.product; // 'iPad'
    platform.manufacturer; // 'Apple'
    platform.layout; // 'WebKit'
    
    // or use the description to put all together
    platform.description; // 'Safari 5.1 on Apple iPad (iOS 5.0)'
    

提交回复
热议问题