我可以告诉我的Chrome扩展程序是否在Windows上运行? [英] Can I tell if my Chrome Extension is running on Windows?

查看:96
本文介绍了我可以告诉我的Chrome扩展程序是否在Windows上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Google Chrome扩展程序中,我需要将文本复制到剪贴板上,并且需要知道我的扩展程序是否安装在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。如果它是Windows,那么我将用\r\\\
来替换结束行,这会在Windows上使多行文本看起来更好。

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. 您可以简单地依靠 navigator.platform

更好的选择是使用Chrome API: chrome.runtime.getPlatformInfo()

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


chrome.runtime.getPlatformInfo(函数回调)

返回有关当前平台的信息。

Returns information about the current platform.

PlatformInfo对象

In the form of a PlatformInfo object.

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


这篇关于我可以告诉我的Chrome扩展程序是否在Windows上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆