Detect the underlying OS in a Chrome Packaged App

醉酒当歌 提交于 2019-12-23 20:08:21

问题


Since packaged apps can run on different platforms, is there any way to distinguish between Windows and Mac ?

I would like to show some help vis-à-vis keyboard shortcuts and being able to detect the OS would help in for example showing Command ⌘C or CtrlC accordingly.


回答1:


You can use window.navigator in JS. Typically that will have the information you're looking for. Probably in window.navigator.platform.




回答2:


You can also use the new chrome.runtime.getPlatformInfo API (https://developer.chrome.com/apps/runtime.html#method-getPlatformInfo, available since Chrome 29).



来源:https://stackoverflow.com/questions/18153367/detect-the-underlying-os-in-a-chrome-packaged-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!