Disable Right-Clicking in Html5 Video

Disable context menu on video element

You can check whether the right mouse button was clicked with event.which in jQuery.
1 refers to left, 2 to middle and 3 to right mouse button.

Try to bind your contextmenu overwrite function when the right button is clicked and unbind it otherwise. I think that should do the trick.

$(document).ready(function () {
$('.video-container').mousedown(function(event) {
if(event.which === 3) {
$('.video-container').bind('contextmenu',function () { return false; });
}
else {
$('.video-container').unbind('contextmenu');
}
});
});

Disable right click on html5 audio element

Using oncontextmenu="return false;" seems to work when the JavaScript doesn't.



Related Topics



Leave a reply



Submit