touchstart event never be triggered on Android Chrome at the first time of
page loading
On Android Chrome, when you create a new tab and access to a page with the
content below, your touches to #touch div have never triggered touchstart
events. Once you reload the page, you can trigger the event. Why? and How
can I avoid this situation?
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>touch start on Android</title>
<style type="text/css">
#touch, #click {
position: relative;
left: 100px;
top: 100px;
width: 200px;
height: 200px;
border: solid 1px black;
}
</style>
</head>
<body>
<div id="touch">Touch</div>
<div id="click">Click</div>
<script type="text/javascript">
document.getElementById('touch').addEventListener('touchstart', function
() {
alert('touch');
}, false);
document.getElementById('click').addEventListener('click', function () {
alert('click');
}, false);
</script>
</body>
</html>
My environment is,
Nexus 7 (2013)
Android 4.30 build number JSS15Q
Chrome 29.0.1547.72 (WebKit version 537.36(@156722), JavaScript version V8
3.19.18.21)
No comments:
Post a Comment