简体   繁体   中英

Detect operating system from Google Chrome Extension

I am developing a Chrome extension, and I need to detect which operating system Chrome is running on but i can't seem to find any info on how to do it. Please Help. Thank You.

Recently added, you can use the getPlatformInfo method in Chrome's own API:

chrome.runtime.getPlatformInfo(function(info) {
    // Display host OS in the console
    console.log(info.os);
});

You would need to search for OS name and version inside window.navigator.appVersion .

If you just want to know a platform, see this answer . You can enhance the code by searching for other user agents .

Here is a detailed list of Chrome user agent strings (click on links to see what they mean).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM