禁用右键单击HTML5视频? [英] Disable Right-Clicking In HTML5 Video?

查看:227
本文介绍了禁用右键单击HTML5视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网站上使用HTML5视频播放器,我想禁用右键点击我的所有视频。

I'm using a HTML5 video player on my website and I want to disable right clicking on all my videos.

我尝试使用此代码并且它没有'工作:

I tried using this code and it doesn't work:

<script type="text/javascript">
$(document).ready(function(){
$('#videoElementID').bind('contextmenu',function() { return false; });
});
</script>

我正在使用Wordpress并将上面的函数放在header.php文件中。

I'm using Wordpress and placed the function above in the header.php file.

如何查看播放机的#videoElementID名称是什么?我尝试了页面上的所有DIV元素,但它仍然无效。

How can I check what is the #videoElementID name for my player? I tried with all the DIV elements on the page and it still doesn't work.

我知道这不会阻止用户下载我的视频,但我真的需要让这项工作。

I know this won't prevent users to download my videos but I really need to make this work.

任何想法?

谢谢。

推荐答案

 $(document).ready(function() {
    $("video").bind("contextmenu",function(){
        return false;
        });
 } );

这应禁用右键单击该页面中的所有视频元素。希望这会有所帮助。

This should disable right click on all the video elements in that page. Hope this helps.

这篇关于禁用右键单击HTML5视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆