如何使用 GWT 检测操作系统?

2024-05-02

Basically what I want to know is to find out if my GWT application is running on a MacOS or any other operating system, to setup the shortcuts properly using cmd on a MacOS and ctrl everywhere else.


您可以使用:

import com.google.gwt.user.client.Window.Navigator;
...

String platform = Navigator.getPlatform();

这将返回一个字符串(与 JavaScript 的相同)navigator.platform)。然后您可以决定类似于以下的操作系统这个脚本 http://www.quirksmode.org/js/detect.html:它只是检查子字符串“Win”/“Mac”/“iPhone”/“Linux”。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何使用 GWT 检测操作系统? 的相关文章

随机推荐