gpt4 book ai didi

javascript - 如何在 Firefox 中禁用视频的单击和双击控件?

转载 作者:行者123 更新时间:2023-12-05 07:49:41 27 4
gpt4 key购买 nike

我有一个视频 ( <video id="video" controls src="foo.webm"></video> ),通过这个视频我有一个 onclickondblclick放。在 Chrome 上这很好用,但在 Firefox 上,他们的“点击切换播放状态”和“双击全屏”会干扰我设置的代码。有没有办法从 Javascript 中禁用这些“功能”?

我试过了event.preventDefault()return false , 但这些对 ondblclick 根本不起作用,并部分使用 onclick .部分工作,这意味着它们完全禁用所有控件,您甚至无法单击视频左下方的播放/暂停按钮来播放/暂停它。

HTML

<div class="videocontainer">
<div class="close">X</div>
<video id="video" controls src="foo.webm"></video>
</div>

JavaScript

var video = document.getElementById('videocontainer');

video.onclick = function(ev) {

ev.preventDefault(); //Disables all click events, including play/pause button
if (ev.target.getAttribute('class') === close) closeVideo(); //if you clicked the close button it will close the video
return false; //Disables all click events, including play/pause button

};

video.ondblclick = function(ev) {

ev.preventDefault(); //doesn't change anything
if (ev.target.nodeName.toLowerCase() === 'video') popoutVideo(); //if you double clicked the video itself it will make the video fixed at the bottom right of the screen
return false; //doesn't change anything

};

最佳答案

只是我添加了 controlsList="nofullscreen"属性。 <video id="vd" src="video.mp4" disablePictureInPicture controls controlsList="nofullscreen"></video>

关于javascript - 如何在 Firefox 中禁用视频的单击和双击控件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37062809/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com