<audio oncontextmenu="return false;" controls controlslist="nodownload">
<source src="audio.mp3" type="audio/mpeg">
Ваш браузер не поддерживает элемент audio.
</audio>Plain javascript to disable the "download" Button from a video in your page:
<script>
window.onload = function() {
video = document.querySelector('video');
if (video) {
video.setAttribute("controlsList", "nodownload");
}
};
</script>If you want to, you can also is querySelectorAll and remove each video. In my example I just have only one video per page.
I using following JavaScript snippet which is working very well:
document.querySelectorAll("video[id^=media-player]").forEach((elem) => elem.controlsList.add("nodownload"));Example: www.ring-cafe-finsterwalde.de/archiv/archiv.html#archiv4
One more control item I was trying to disable, additionally to 'download' - is 'picture-in-picture'.
Sadly there`s no property, for that purpose to be added in the controlsList. But there is an attribute - disablePictureInPicture you can add to the Element to disable pip.
Example disabling both download and picture-in-picture:
<video disablepictureinpicture controlslist="nodownload">...</video>Details: https://wicg.github.io/picture-in-picture/#disable-pip
jQuery
$("video").on('contextmenu',function() { return false; });