目前,为了检测触摸屏设备,我在javascript中使用了以下内容:
if ('createTouch' in document) {
// do touchscreen-specific stuff
}
我看到许多开发人员使用ontouchstart,如下所示:
if ('ontouchstart' in document) {
// do touchscreen-specific stuff
}
createTouch和ontouchstart有什么区别?哪一种最安全?除了这两者,还有其他简单可靠的替代方案吗?