无法识别是linux桌面机还是android设备使用navigator.userAgent
or navigator.platform
因为某些 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
navigator.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桌面可以有触摸或者它可以模拟触摸。请帮忙
Update:即使桌面浏览器的模拟设备处于活动状态,该解决方案也应该检测 Linux。查看详情 https://stackoverflow.com/questions/8068052/phonegap-detect-if-running-on-desktop-browser/29818615#29818615
你可以试试这个:
if (navigator.userAgent.match(/android/i)) {
// it's andorid
} else if (navigator.userAgent.match(/linux/i)) {
// it's linux
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)