“视频”标签后,触控事件在 iPad 上停止工作

Touch Events stop working on iPad after the Video tag

本文关键字:事件 iPad 停止工作 视频 标签      更新时间:2023-09-26

我有一个应用程序,可让您左右滑动以查看不同的屏幕,或者单击"下一个"和"上一个"按钮进行导航。

if(isMobile){
    detectSwipe = true;
    document.addEventListener('touchstart',TouchStart,false);
    document.addEventListener('touchmove',TouchMove,false);
    document.addEventListener('touchend',TouchEnd,false);
    document.addEventListener('touchend',TouchCancel,false);
}
$("#prevBtn").on('touchstart click', function () { 
    ...
}

问题是由于某种未知原因,当它到达带有视频标签的屏幕时,所有按钮都变得不可单击,只有滑动事件仍然处于活动状态。这只发生在iPad上,但是,在桌面上它工作正常。

<video width="960" height="560">
    <source src="video.mp4" type="video/mp4"/>
    <source src="video.ogg" type="video/ogg"/>
    <source src="video.webm" type="video/webm"/>
    Your browser does not support the video tag.
</video>

我也尝试使用嵌入的 youtube 视频而不是视频标签,但问题仍然存在。

您必须将

视频元素的控件设置为false并设置自己的控件,才能使其正常工作。