我正在尝试将一些事件附加到我的 iPad 网络应用程序中的 HTML5 视频元素,但它们似乎没有触发?我已经在设备和模拟器上测试了这个并得到了相同的结果。然而,这些事件(至少对于 onclick)在桌面 Safari 中运行良好。我还尝试将视频元素交换为 div 并且事件触发正常?有没有其他人遇到过这个并有解决方法的想法?
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Test video swipe</title>
</head>
<body>
<video src='somevid.mp4' id='currentlyPlaying' width='984' height='628' style='background-color:#000;' controls='controls'></video>
<script>
var theVid = document.getElementById("currentlyPlaying");
theVid.addEventListener('touchstart', function(e){
e.preventDefault();
console.log("touchstart");
}, false);
theVid.addEventListener('click', function(e){
e.preventDefault();
console.log("click");
}, false);
theVid.addEventListener('touchmove', function(e){
console.log("touchmove");
}, false);
theVid.addEventListener('touchend', function(e){
console.log("touchend");
}, false);
theVid.addEventListener('touchcancel', function(e){
console.log("touchcancel");
}, false);
</script>
</body>
</html>