using this code:
<h2 id="status">
0, 0
</h2>
<script type="text/javascript">
$('html').mousemove(function(e){
$('#status').html(e.pageX +', '+ e.pageY);
});
</script>
In Windows browser like firefox, It’s ok to see the mouse postion when I move mouse, but when I run this page in android(2.1) browser, I can not get the continuous event when I touch the screen, It just trigger the event when I tap the screen, why? and how to get the continuous mousemove event when I touch the screen?
Use the
touchmoveevent instead (works on my Android browser on Froyo), although there are some problems with it — the browser only updates the div when the touch has been released, however the event is still fired for every touch movement. This can be demonstrated by changing the code to this:This is due to a bug in the Android browser — you need to call
event.preventDefault()to make this work as expected:Official bug details: available here
To detect the current X and Y position you should use the
event.touchesobject:jQuery creates it’s own “version” of the event object which doesn’t have the native browsers properties such as
.touches— so you need usewindow.eventinstead