简体   繁体   中英

Can I tell if my Chrome Extension is running on Windows?

In my Google Chrome Extension I need to copy text onto the Clipboard, and I need to know if my extension is installed on Windows OS or not. Is it possible?

PS. If it is Windows, then I will replace end-lines with "\\r\\n" , which makes multi-line text look better on Windows.

Two ways, at least

  1. You can simply rely on navigator.platform

  2. Better option is to use Chrome API: chrome.runtime.getPlatformInfo() :

    chrome.runtime.getPlatformInfo(function callback)

    Returns information about the current platform.

    In the form of a PlatformInfo object .

     chrome.runtime.getPlatformInfo( function(info) { if(info.os == "win") { /* do stuff */ } }); 

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