Javascript touchstart上event.layerX和event.layerY的iOS 4问题
此代码:Javascript touchstart上event.layerX和event.layerY的iOS 4问题,javascript,jquery,cordova,ios4,Javascript,Jquery,Cordova,Ios4,此代码: $(doc).on('touchstart touchend', function(ev){ var or = ev.originalEvent; console.log('y: '+or.layerY+' x '+or.layerX); }); 正在显示我在iOS 5中点击的位置的坐标,但在iOS 4中,两个坐标都为0doc是一个包含iframe的contentDocument的变量,我使用的是jQuery 1.7.1。有什么想法吗?我最终使用了属性ev.origi
$(doc).on('touchstart touchend', function(ev){
var or = ev.originalEvent;
console.log('y: '+or.layerY+' x '+or.layerX);
});
正在显示我在iOS 5中点击的位置的坐标,但在iOS 4中,两个坐标都为0
doc
是一个包含iframe的contentDocument
的变量,我使用的是jQuery 1.7.1。有什么想法吗?我最终使用了属性ev.originalEvent.touchs[0]。pageX
和ev.originalEvent.touchs[0]。pageY
。我不知道为什么layerX
和layerY
不能正常工作,但是其他的方法似乎使这个技巧变得不那么有效了。不管出于什么原因,“pageX”不是最好的方法,只是为了防止触摸时滚动条移动。“clientX”或“screenX”可能更好。