我正在尝试将一些事件附加到 iPad Web 应用程序内的 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>
如果您使用控件属性,iPad 上的视频元素将吞噬事件。如果您希望元素响应触摸事件,您必须提供自己的控件。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)