无法使用 navigator.userAgent
或 navigator.platform
识别它是 linux 台式机还是 android 设备,因为某些 android 设备有字符串 linux
在两者中。详情如下
Device OS navigator.platform
--------------------------------------------------------------------
Samsung Galaxy S3 Android 4.3 Linux armv7l
HTC One Android 4.4.2 Linux armv7l
Sony Xperia Z Android 4.2.2 Linux armv7l
Motorola Moto G Android 4.4.2 Linux armv7l
Samsung Galaxy Tab 3 Android 4.2.2 Linux i686
Nexus 10 Android 4.4.2 Linux armv7l
Lenovo Yoga Android 4.2.2 Linux armv7l
导航器.userAgent
Mozilla/5.0 (Linux; U; Android 2.2; en-us; SCH-I800 Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
即使我尝试使用触摸事件,但 linux 桌面可以有触摸或者它可以模拟触摸。请帮忙
更新:即使桌面浏览器的模拟设备处于 Activity 状态,该解决方案也应检测到 Linux。 View Details
最佳答案
你可以试试这个:
if (navigator.userAgent.match(/android/i)) {
// it's andorid
} else if (navigator.userAgent.match(/linux/i)) {
// it's linux
}
关于Javascript : Identify whether it is a desktop Linux or Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29815326/