【发布时间】:2014-08-01 10:01:54
【问题描述】:
我有一个小功能可以检测我的用户是否在完美运行的触控设备上...
function is_touch_device() {
return (('ontouchstart' in window) || (navigator.MaxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0));
}
if(!is_touch_device()) {
window.location.href = 'index.html';
}
我想添加一个条件,如果设备是 ipad,则不执行重定向。
我试过了……
function is_touch_device() {
var isiPad = navigator.userAgent.match(/iPad/i) != null;
if( !isiPad ){
return (('ontouchstart' in window)
|| (navigator.MaxTouchPoints > 0)
|| (navigator.msMaxTouchPoints > 0));
}
};
if(!is_touch_device()) {
window.location.href = 'index.html';
}
但它会阻止触摸设备重定向,事实上,所有这些,有什么想法吗?
【问题讨论】:
标签: javascript jquery ios ipad