[英]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. 在我的Google Chrome扩展程序中,我需要将文本复制到剪贴板上,我需要知道我的扩展程序是否安装在Windows操作系统上。 Is it possible?
可能吗?
PS. PS。 If it is Windows, then I will replace end-lines with
"\\r\\n"
, which makes multi-line text look better on Windows. 如果它是Windows,那么我将用
"\\r\\n"
替换结束行,这使得多行文本在Windows上看起来更好。
Two ways, at least 两种方式,至少
You can simply rely on navigator.platform
您可以简单地依赖
navigator.platform
Better option is to use Chrome API: chrome.runtime.getPlatformInfo()
: 更好的选择是使用Chrome API:
chrome.runtime.getPlatformInfo()
:
chrome.runtime.getPlatformInfo(function callback)
Returns information about the current platform.
返回有关当前平台的信息。
In the form of a PlatformInfo object . 以PlatformInfo对象的形式。
chrome.runtime.getPlatformInfo( function(info) { if(info.os == "win") { /* do stuff */ } });
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.