OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Disable Right-Clicking In HTML5 Video?

  • Thread starter Thread starter user3517251
  • Start date Start date
U

user3517251

Guest
I'm using an 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:

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

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

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.

<p>I'm using an HTML5 video player on my website and I want to disable right-clicking on all my videos.</p>
<p>I tried using this code and it doesn't work:</p>
<pre><code><script type="text/javascript">
$(document).ready(function(){
$('#videoElementID').bind('contextmenu',function() { return false; });
});
</script>
</code></pre>
<p>I'm using WordPress and placed the function above in the <code>header.php</code> file.</p>
<p>How can I check what is the <code>#videoElementID</code> 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.</p>
 
Top