在我的 Google Chrome 扩展程序中,我需要将文本复制到剪贴板上,并且我需要知道我的扩展程序是否安装在 Windows 操作系统上。可能吗?
附言。如果是 Windows,那么我会将结束行替换为 "\r\n"
,这使得多行文本在 Windows 上看起来更好。
最佳答案
至少有两种方式
您可以简单地依赖
navigator.platform
更好的选择是使用 Chrome API:
chrome.runtime.getPlatformInfo()
:chrome.runtime.getPlatformInfo(function callback)
Returns information about the current platform.
以 PlatformInfo object 的形式.
chrome.runtime.getPlatformInfo( function(info) { if(info.os == "win") { /* do stuff */ } });
关于javascript - 我可以判断我的 Chrome 扩展程序是否在 Windows 上运行吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25617688/