如何使用Javascript检查设备是否为Windows Surface Tablet,浏览器是chrome还是IE。 我试过以下代码
function is_touch_device()
{
try {
document.createEvent("TouchEvent");
return true;
} catch (e) {
return false;
}
}
if(is_touch_device() )
{
if(navigator.userAgent.toLowerCase().indexOf('chrome')>-1)
{
//some stuff
}
}
我搜索过useragent 但我没有准确的表面。 如何检查设备是否为表面,浏览器是否为chrome或IE
答案 0 :(得分:1)
使用导航器对象可以访问这些数据字段
navigator.appName <- gets app name may be misleading so also get the appCodeName
navigator.appCodeName; <-- alternate name
navigator.platform; <-- platform the user is on
答案 1 :(得分:1)
虽然你可以使用导航器对象来达到你的目的,但我建议你使用现代化器。
答案 2 :(得分:1)
'cxfreeze' is not recognized as an internal or external command, operable program or batch file.
此方法返回真正的Surface设备.....