OnTouchEnd not working for Android Froyo 2.2?

The following html, when opened in the default browser on Android 2.2, logs the touchstart and touchmove events properly, but does not affect the events. Any idea why?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"/>
</head>
<body>
<div id="a" onTouchStart="touchstartFunction(event);"
            onTouchMove="touchmoveFunction(event);"
            onTouchEnd="touchendFunction(event);"
            style="width:300px ; height:300px;background:red;"></div>
<script>
    function touchstartFunction(event){
        event.preventDefault();
        var touch = event.touches[0];
        document.getElementById('touchMoveTextbox').value = "Touch start at " + touch.pageX + "x" + touch.pageY;
    }
    function touchmoveFunction(event){
        event.preventDefault();
        var touch = event.touches[0];
        document.getElementById('touchMoveTextbox').value = "Touch move at " + touch.pageX + "x" + touch.pageY;
    }
    function touchendFunction(event){
        event.preventDefault();
        var touch = event.touches[0];
        document.getElementById('touchMoveTextbox').value = "Touch end at " + touch.pageX + "x" + touch.pageY;
    }
</script>
<input type='textbox' size="30" id='touchMoveTextbox' >
</body>
</html>
+3
source share
1 answer

Believe me, you could experience this: touchhend event does not work on Android

because you are accessing [0], which is empty in the latter case and causes a javascript error.

+3
source

Source: https://habr.com/ru/post/1780953/


All Articles